W
william.w.oneill
I have an application that takes a few command line parameters. As
recommended by others in this group, I'm using a named mutex to ensure
that only one instance of the application is running. My question is
how to elegantly pass a command line parameter from Instance_B to
Instance_A where Instance_A was running prior to Instance_B.
For example, the user can launch the program by passing a file name as
a command line argument. The program will display the file after the
program launches. If a second instance is launched, I want the first
instance to display the file and the second instance to close.
How I'm doing it now is clumsy. When Instance_B starts and notices
Instance_A is already running, I write a temp file to the user's area
that contains the name of the user's file to open. Instance_A polls
the temp file and opens the user's file when temp file is created.
Ugly, but it works.
Have any of you done something like this before? I can think of a few
other solutions but they are overly complex.
Thank you,
Bill
recommended by others in this group, I'm using a named mutex to ensure
that only one instance of the application is running. My question is
how to elegantly pass a command line parameter from Instance_B to
Instance_A where Instance_A was running prior to Instance_B.
For example, the user can launch the program by passing a file name as
a command line argument. The program will display the file after the
program launches. If a second instance is launched, I want the first
instance to display the file and the second instance to close.
How I'm doing it now is clumsy. When Instance_B starts and notices
Instance_A is already running, I write a temp file to the user's area
that contains the name of the user's file to open. Instance_A polls
the temp file and opens the user's file when temp file is created.
Ugly, but it works.
Have any of you done something like this before? I can think of a few
other solutions but they are overly complex.
Thank you,
Bill