Solved

Shared Memory and inheritance

Posted on 1998-03-27
1
200 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:gunn
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 110 total points
ID: 1412338
This is not that unusual. One idea is to not hardcode a specific name, but to use one based off of the processId of the parent. For example, instead of using MY_SHARED_MEM as the name of the filemap, use MY_SHARED_MEM_%PROCESSID%. Then when the parent process launches the child, pass the child the name as an argument.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now