Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recently, I get a problem in one of my Win32 applications. The application calls CreateEvent with a unique string, to determain whether another instance of the application is already running. Then the application exits if the call’s GetLastError() == ERROR_ALREADY_EXISTS. It works as expected in most computers. But when it is running in virtual box, it does not work. And when I use CreateMutex, it works again. Can anyone tell me Why the ‘CreateEvent’ does not work while the ‘CreateMutex’ does
Posted
Updated 8-Jan-13 22:10pm
v3

1 solution

A very thorough treatment of the whole subject can be found here[^] in an article by Jeff Prosise (who I have a great deal of respect for). The article is a bit old but the answers are still relevant.

If you are using VS2008 or greater, you can apparently go to the project properties and check the box "Make single instance application" (I haven't tried it but it is described here[^]).
 
Share this answer
 
Comments
Member 7857575 15-Jan-13 0:35am    
Thank you Mr Brydon
It’s my great honor to receive your reply. especially the message is from the other side of the world.

I read the articles you mentioned above, but I cannot find the "Make single instance application" option (maybe it applies only in VB). The first article is great.

Although I still don’t know why ‘CreateEvent’ doesn’t work. But it is not particularly important. After all it’s in virtualbox

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