Using Mutex Objects
Mutex (or "Mutual Exclusion") kernel objects are used to ensure that global variables or resources are accessed exclusively by a piece of code. In this respect, they provide the same functionality as critical sections. However, they are more flexible. For example, critical sections can only be used to ensure exclusivity within a single process, whereas mutex objects can be used across processes.
The following steps are required when using mutex kernel objects:
Create a new mutex or open an existing mutex by calling the function CreateMutex.
Call WaitForSingleObject when entering critical code.
Call ReleaseMutex when the critical code execution is complete.
Call CloseHandle on the mutex when the mutex is no longer required.
Get Windows® CE 3.0 Application Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.