Re: Passing arguments to a running application

From: Michael J. Salamone [eMVP] (mikesa#at#entrek#dot#com)
Date: 06/22/04


Date: Tue, 22 Jun 2004 09:15:25 -0700

Uhh...

The second instance of your program is finding the first instance, switching
to it (by calling SetForegroundWindow, which has the effect of sending
WM_ACTIVATE to the first instance) and then exits. So you're left with just
the first instance running, with whatever parameters it was initially
started with.

So, you could either

1) allow the second instance to run (you might have to fight MFC to do it,
not sure) with whatever parameters it was given. Don't have it switch to
the running instance. You then have two instances running (this would be
bad, especially on Pocket PC, because there is no convenient way for the
user to switch to the existing instance - or even identify it, unless each
instance has its own separate caption)

2) have the second instance, upon discovering the first instance, use
PostMessage(hWndOfFirstInstance, WM_COPYDATA, ...) and pass the new
parameters to the existing instance. The existing instance would have to
have a handler for WM_COPYDATA to receive the parameters, and then do
whatever is correct for your application.

-- 
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"Fab W" <fabrice_wil@yahoo.fr> wrote in message
news:ED513393-22EC-4188-BD5C-898EFD275303@microsoft.com...
> Hello everyone,
>
> Here is my problem :
> I'm currently working on a PDA under pocketPC 2003.
> When I call my not-running executable with arguments, then it opens well
and takes in consideration the arguments given (theApp.m_lpCmdLine).
> But when I desire to launch the same application with other arguments
while it is already running, then the window of my application comes in
foreground, but the new parameters are not taken in consideration.
>
> So I know when my app is called for the the second time (thanks to the
reception of the WM_ACTIVATE message), but where should I get this arguments
then??
>
>
> I hope someone could answer my request.
>
> Regards,
>
>
> Fab W
>


Relevant Pages

  • Re: Passing arguments to a running application
    ... "You're left with just the first instance running, with whatever parameters it was initially started with". ... > The second instance of your program is finding the first instance, ... Don't have it switch to ...
    (microsoft.public.pocketpc.developer)
  • Re: Howd He Do That Sound?
    ... I only have that low-rez ram clip to judge by but, ... second instance of the effect, though, I hear no clicks at all (of toggle ... switch throws or something). ... were able to filter out the clicks for the last half of the first instance ...
    (alt.guitar.beginner)
  • Where is the file
    ... and if I open a second instance of XL the file opens but if I switch to the first instance the second is gone. ...
    (microsoft.public.excel.crashesgpfs)
  • Where is the file
    ... and if I open a second instance of XL the file opens but if I switch to the first instance the second is gone. ...
    (microsoft.public.excel.crashesgpfs)
  • Where is the file
    ... and if I open a second instance of XL the file opens but if I switch to the first instance the second is gone. ...
    (microsoft.public.excel.crashesgpfs)