views:

609

answers:

2

We have multiple MFC apps, which use CMutex( false, "blah" ), where "blah" allows the mutex to work across process boundaries.

One of these apps was re-written without MFC (using Qt instead). How can I simulate the CMutex using Win32 calls? (Qt's QMutex is not inter-process.) I prefer not to modify the MFC apps.

+1  A: 

The following funcs will probably be what you want, they are all documented on MSDN.

CreateMutex(...)
WaitForSingleObject(...)
ReleaseMutex(...)
RichS
+3  A: 

For inter-process mutexes you want these calls:

CreateMutex

WaitForSingleObject

ReleaseMutex

CloseHandle

These are the underlying Win32 API calls that CMutex is a wrapper around.

For in-process only mutexes you can also use these calls, which are faster:

InitializeCriticalSection

EnterCriticalSection

LeaveCriticalSection

DeleteCriticalSection

Don Neufeld