Alright so what I am trying to do is essentially create a program that, when it is already executed, can be “executed” again, detect the already existing process and instead of creating another process, execute a function in the existing process.
Any ideas?
It’s possible I am going at this all wrong. I am trying to adapt this open-source Virtual Printer (http://sourceforge.net/projects/imageprinter/) to an application of mine. The printer prints for example a PDF to a file and it seems also has a feature to launch an application. I need to grab the PDF into my own application for handling at this point and the user needs to be able to append more pdfs by printing them to this printer.
The way I was planning to handle it is to have the application check that folder for new files everytime it opens and a command is called when a new file is printed. Is there another way to import the pdf data more directly to a running process?
1: The typical solution is to use a named mutex for this. See this question asked on MSDN for more details.
2: Use one of these functions (maybe
FindWindowEx?) and (if needed) some way to get the information for locating theHWNDbetween the two processes. Sorry I can’t be more clear, there are way too many ways to do this and it varies from application to application.3: After you know the other application is running, you can use SendMessage with your own
UINT message(make sure it doesn’t clash with an existing message) and make sure to handle the special message in your message loop.