Constructs a named or unnamed CMutex object.
CMutex( BOOL bInitiallyOwn = FALSE, LPCTSTR lpszName = NULL, LPSECURITY_ATTRIBUTES lpsaAttribute = NULL );
To access or release a CMutex object, create a CMultiLock or CSingleLock object and call its Lock and Unlock member functions. If the CMutex object is being used stand-alone, call its Unlock member function to release it.
After creating the CMutex object, use GetLastError to ensure that the mutex did not already exist. If the mutex did exist unexpectedly, it may indicate a rogue process is squatting and may be intending to use the mutex maliciously. In this case, the recommended security-conscious procedure is to close the handle and continue as if there was a failure in creating the object.