switch to existing instance [modified]
-
My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G
modified on Wednesday, March 4, 2009 1:39 PM
-
My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G
modified on Wednesday, March 4, 2009 1:39 PM
-
Is there some reason you bolded your entire post? I'm so distracted by it I can't even read the post.
-
Is there some reason you bolded your entire post? I'm so distracted by it I can't even read the post.
-
My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G
modified on Wednesday, March 4, 2009 1:39 PM
-
negativeG wrote:
I want to make that instance be get focus and be the top most application.
-
Sure, but how do I find the hWnd for the Applet (it is a dialog based) from my App? There is some recourse if I start the Applet from my App using CreateProcess, but if it is run from the command line, my app has no knowledge of it. -G
-
My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G
modified on Wednesday, March 4, 2009 1:39 PM
negativeG wrote:
I want to make that instance be get focus and be the top most application.
See the
InitInstance()
method in this example."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
negativeG wrote:
I want to make that instance be get focus and be the top most application.
See the
InitInstance()
method in this example."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons