Solved

Shared Memory and inheritance

Posted on 1998-03-27
1
208 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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