8/17/09

How I can make sure that a single instance of my app should be executing at a time?

Answers:

Create one Mutex object with a unique name. Since Mutex is a Kernel object that can be identified uniquely and will be availble for all applications to check.
ex.
hMutex = CreateMutex ( NULL, TRUE, _T("UniqMutexName") );

When application is launched first time above mutex will be created.
But if it is tried to launched second time. it will try to create another Mutex with same name used for creating mutex object at the time of first launch of application.
Thus it will fails to create the mutex object and application can return from further launching.

No comments: