Re: Shell works differently in two different programs




"Martin" <martinvalley@xxxxxxxxxxx> wrote in message
news:fh29j1hmd6u95vsauke1mt0qtj9mendujg@xxxxxxxxxx
> I'm using the following statement in a VB6 program to start/show
> another program:
>
> Call Shell(PathName$, vbNormalFocus)
>
> where PathName$ is something like
> "C:\SomeFolder\SecondProgramName.exe"
>
> This works exactly as intended: if the Second Program is not running,
> it starts up; if it is already running, it's brought to the
> foreground.
>
> Now the problem: I use this exact same statement in another program to
> start/show a different Second Program and, while it starts a new
> instance of the second program all right, it will NOT bring an
> already-running instance to the foreground.
>
> Both of these situations are on the SAME computer (Windows XP, SP2).
> One works - one doesn't. I can go back and forth between them - one
> works, the other one doesn't. It doesn't matter whether I'm in the IDE
> or running the compiled versions - one works, the other doesn't.
>
> Can anyone give me some idea of what I might look for here?
>
> Any thoughts at all?


This has NOTHING to do with the Shell function (or any other means of
running a program, for that matter). It has EVERYTHING to do with how each
app was written (IMO, you kind of confused things by referring to both apps
you're shelling to as the "second app" <g> ). IOW, the first app you're
shelling to was specifically written to bring a previous instance of itself
to the foreground if run again. The second was not written to do this.

With that said, about the only thing you can do is check yourself if this
second program is already running and, if it is, bring it to the foreground;
otherwise, launch it with Shell.

--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Shell works differently in two different programs
    ... I'm using the following statement in a VB6 program to start/show ... if the Second Program is not running, ... already-running instance to the foreground. ...
    (microsoft.public.vb.general.discussion)
  • Re: Shell works differently in two different programs
    ... > I'm using the following statement in a VB6 program to start/show ... > This works exactly as intended: if the Second Program is not running, ... Many apps do not handle the situation. ... and find a running instance and bring it to the front but the best way to do ...
    (microsoft.public.vb.general.discussion)

Loading