Link to home
Start Free TrialLog in
Avatar of SuperMario
SuperMario

asked on

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
Avatar of SuperMario
SuperMario

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of captainkirk
captainkirk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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

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 .
InitInstance() -- YEE-HAW!

I was trying InitApplication. Thanks, man!

-D