Singleton using mutex for windows application (exe)
-
Hi, in my application I have to support single instance functionality I tried with FindWindow and sendmessage but it failed in some times so I want to try with mutex,can anybody suggest me how to support single instance with mutex? Thanks in advance....
-
Hi, in my application I have to support single instance functionality I tried with FindWindow and sendmessage but it failed in some times so I want to try with mutex,can anybody suggest me how to support single instance with mutex? Thanks in advance....
you can add some code like this... in your application initinstance HANDLE hMutex = CreateMutex( NULL, TRUE, "MyMutex" ); if( GetLastError() == ERROR_ALREADY_EXISTS ) {//application is already running. dont proceed further CloseHandle( hMutex ); return FALSE; }
-
Hi, in my application I have to support single instance functionality I tried with FindWindow and sendmessage but it failed in some times so I want to try with mutex,can anybody suggest me how to support single instance with mutex? Thanks in advance....
-
since w2k sp4 it is better to use global mutexes: HANDLE hMutex = CreateMutex( NULL, TRUE, "Global\\MyMutex" ); to aovid conflicts in multiple sessions.
Greetings from Germany
-
-
Hi, in my application I have to support single instance functionality I tried with FindWindow and sendmessage but it failed in some times so I want to try with mutex,can anybody suggest me how to support single instance with mutex? Thanks in advance....
See the link below. There is a video and source code from microsoft, to show how to restrict to a single instance. also switch to active instance when running a new instance. http://msdn.microsoft.com/en-us/visualc/bb924354.aspx[^]