OpenFileMapping and CreateFileMapping
2010-10-18
In C++ projects, to share data, multiple processes can use memory-mapped files that the system paging file stores.
First process create memory file and other process open this memory file.
The name of the file mapping object to be opened has the following rules (from MSDN):
**Terminal Services**: The name can have a "Global\" or "Local\" prefix to explicitly open an object in the global or session name space. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Name Spaces. **Windows XP**: Fast user switching is implemented using Terminal Services sessions. The first user to log on uses session 0, the next user to log on uses session 1, and so on. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users. **Windows 2000**: If Terminal Services is not running, the "Global\" and "Local\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.
In new OS such as Windows 7, the mapping object name should include with "Global" so that other processes can access this mapping object.
There is a good example on MSDN: