Shared Memory and inheritance
Posted on 1998-03-27
I am currently using CreateFileMapping() and MapViewOfFile() to create a block of shared memory using 0xFFFFFFFF as the first parameter of the CreatFileMapping() call so its not associated with a file but uses the system paging file.
However, by giving it a name "MY_SHARED_MEM", so both processes will attach to the same area, this leaves me with a problem.
At some point in time, these applications may run on an NT server and so there may be multiple processes running. I only want the main process and the child process *of that main process* to access the shared memory. As it is, I 'think' that if another uses starts a 2nd main process and launches the child, they will attach to the original area, becuase of the name correct?
How can I avoid this, and yet still use the system paging file? . use the CreateProcess to launch the child with handle inheritance set to TRUE if thats necessary to do this. I've read about DuplicateHandle() but not sure how to set it up..can't quite get a grasp on it.
Any help would be appreciated