Microsoft Windows CE 3.0  

Interprocess Synchronization

This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

All processes protect against the casual exchange of data; however, occasionally two processes may need to communicate with each other. One method that enables one process to communicate with another 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 CreateEventor CreateMutexfunction. Other processes can open a handle to the object by using its name in another call to the CreateEventor CreateMutexfunction.

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. Once a process has created a named event or mutex object, other processes can use the name to call the appropriate function, either CreateEventor CreateMutex, to open a handle to the object. Name comparison is case-sensitive.

The names of event and mutex objects do not share the same name space. The following code example shows how to use object names by creating and opening named objects. The first process uses CreateMutexto create the mutex object. Note that the function succeeds even if there is an existing object with 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; } // End of MakeMyMutex example code

 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.