Start New Discussion within our Software Development Community

Hi, say I have an app running in the background from startup. Now say I added an option to the explorer context menu to launch the app by right-clicking a file (how would one pass that filename in as a parameter by the way?), I would only want one instance of my application open.

So in the new one that opens, is there a way for it to tell the already open one to call a specific function? And send that filename to it?

I really hope that was clear enough

I have attached a project that does what you want.
Parameters are passed on the command line. So if you set a File Association with your application, and double click it in the explorer, it will launch you application and pass the filename as a parameter.

The example project determines if your program is already running. If it is, then it will take its command line parameter and send a message to the first instance. Then closes itself. The first instance will receive the message and you can handle the file from that point on.

--Jerry

This article has been dead for over six months. Start a new discussion instead.