Instance detection

How can I get an application to launch itself when another program's instance is constructed?

(user executes prog1.exe, prog2.exe autolaunches itself)

-D
LVL 3
SuperMarioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SuperMarioAuthor Commented:
Or, better yet -
There is a Plugins menu in the target application. What I would REALLY like to do is write a .dll that will ShellExecute() my function when the word Load is selected from the Plugins menu.

I am not sure where to put the ShellExecute() in the .dll code.

-D
0
captainkirkCommented:
In the first version of your question, you could place the ShellExecute() call in the InitInstance() function of your app.

In the second version, it sounds like you would like to kick off the program in response to a menu selection. If this is correct, just create a command handler for the menu item which will then contain the ShellExecute() call...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
azamiCommented:
I'm not sure I follow your question.  Are prog1 and prog2 both your own development?  If so, why not just launch prog2.exe from it at startup or in response to a user command or whatever.  You can use _exec or _spawn functions from the RTL, or CreateProcess from the Win32 API.

If you don't have control over the code in prog1.exe, then how to get it to launch prog2.exe depends on what customization prog1's developer included for customization.

ShellExecute() is just a way to have Windows automatically choose the program to launch based on a file extension; it's what Windows Explorer uses to auto-launch NOTEPAD when you double-click a .txt file.  If this is really what you want, it only requires creating the file association (in Explorer) and handling a command-line input of the file to load.  For more advanced processing, there are some helper functions: RegisterShellFileTypes and EnableShellOpen; I haven't used these and so can't really elaborate.

HTH
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

SuperMarioAuthor Commented:
Okay, lemme re-word this.

There are several plugins that can be loaded from this program's menu. I do not have control over the program, but plugins are encouraged to be written for it.

There is a menu called Plugins. Below it, there are more popups with the names of the files in your Plugins folder. To the right of each popup there is a Load command like so:

&Plugins
--------
App1Dll -> Load

If the executable is in the Plugins folder and so is the DLL (the exec doesn't show up on the popup) what do I need to put in the DLL to launch the exe when the DLL is loaded?

-D
0
WxWCommented:

If the DLL is loaded by the application , you can use the CreateProcess to start any EXE . If the DLL is not loaded , you can't .
0
SuperMarioAuthor Commented:
InitInstance() -- YEE-HAW!

I was trying InitApplication. Thanks, man!

-D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.