Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows API
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 8-Jan-13 22:08pm
Edited 8-Jan-13 22:10pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]).
  Permalink  
Comments
Member 7857575 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100