Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all

I have a program written in VC6 (running on XP) that I want to stop from having multiple copies open. I want it to check whether there is another instance of itself running on start up and close if there is. Using FindWindow() doesnt work as it finds itself!

Thanks for any help

Mike
Posted

You can try creating a named mutex with CreateMutex() API and checking the result with GetLastError(). When the second instance of the app tries to create it, GetLastError() will return ERROR_ALREADY_EXISTS as the mutex is already created by the first instance.

http://vcfaq.mvps.org/mfc/2.htm[^]
 
Share this answer
 
Thank you very much - works a treat!

Mike
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900