Re: Passing arguments to a running application
From: Michael J. Salamone [eMVP] (mikesa#at#entrek#dot#com)
Date: 06/22/04
- Next message: Andrew Kennard: "Re: max characters in edit window ?"
- Previous message: Carl: "Re: FileNotFound Exception"
- In reply to: Fab W: "Passing arguments to a running application"
- Next in thread: Fab W: "Re: Passing arguments to a running application"
- Reply: Fab W: "Re: Passing arguments to a running application"
- Messages sorted by: [ date ] [ thread ]
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 >
- Next message: Andrew Kennard: "Re: max characters in edit window ?"
- Previous message: Carl: "Re: FileNotFound Exception"
- In reply to: Fab W: "Passing arguments to a running application"
- Next in thread: Fab W: "Re: Passing arguments to a running application"
- Reply: Fab W: "Re: Passing arguments to a running application"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|