All memory allocated by the methods described above (GlobalAlloc, LocalAlloc, malloc, HeapAlloc, or VirtualAlloc ) is inaccessible to other processes. Note that memory allocated by DLL code is in the address space of the process that invoked the DLL, and is not accessible by other processes using the same DLL.
Shared memory is implemented by file mapping, which is a two step process. First a file mapping object must be created; and then using that object, a view of the file can be mapped into the virtual address space of a process. A file mapping object can be created to map a named file in the file system or to map a portion of the system's paging file. You can specify the size in bytes of the mapped region, and the read and write access to the region. The mapping object is referred to by a handle, which is used to map a view of the file. This handle can be inherited by child processes or communicated to other processes to be duplicated. Alternatively, a name can be associated with a file mapping object. This name can then be used by other processes to obtain a handle to the object. To implement shared memory, each process must use a handle to the same file mapping object to map a view of the file into its virtual address space. Each view may consist of all or any part of the file. If multiple processes map views of a single mapping object, the views are guaranteed to be coherent. However, if multiple mapping objects are created for the same file, the views are not guaranteed to be coherent.