Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Interprocess Synchronization

Windows Mobile 6.5
A version of this page is also available for

All processes prevent casual exchange of data. However, occasionally two processes might need to communicate with each other. One method that enables processes to communicate is called interprocess synchronization.

Because multiple processes can have handles to the same event or mutex object, these objects can be used to accomplish interprocess synchronization.

The process that creates an object can use the handle returned by the CreateEvent or the CreateMutex function.

Other processes can open a handle to the object by using the object name in another call to the CreateEvent or CreateMutex functions.

Named objects provide a way for processes to share object handles.

The name specified by the creating process is limited to the number of characters that are defined by MAX_PATH. It can include any character except the backslash (\) path-separator character.

After a process creates a named event or mutex object, other processes can use the name to call the appropriate function, either CreateEvent or CreateMutex, to open a handle to the object.

Name comparison is case-sensitive.

Each object type, such as memory maps, semaphores, events, message queues, mutexes, and watchdog timers, has its own separate namespace. Empty strings ("") are handled as named objects. On Windows desktop-based platforms, synchronization objects all share the same namespace.

The following code example shows how to use object names by creating and opening named objects. The first process uses CreateMutex to create the mutex object. The function succeeds even if an existing object has the same name.

HANDLE MakeMyMutex (void)
   HANDLE hMutex;
   hMutex = CreateMutex
      NULL, // No security attributes
      FALSE, // Initially not owned
      TEXT("MutexToProtectDatabase")); // Name of mutex object
      if (NULL == hMutex)
         // Your code to deal with the error goes here.
   return hMutex;

Community Additions

© 2015 Microsoft