• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

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
0
SuperMario
Asked:
SuperMario
1 Solution
 
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now