Storing the value in memory independent of the process
I need to store the value somewhere temporarily for a while, for example using process A. Process A can exit after storing the value in memory. After some time, process B accesses the same memory location and reads the value. I need to keep in memory because I don't want the data to persist across reboots. But as long as the system is running, regardless of the process, the data must be available. I've tried MailSlots and temp files on Windows, both seem to have an issue where the process link count drops to zero, objects are not persisted in memory. What is the appropriate mechanism for doing this on Windows, preferably using the Win32 API?
- Ganesh
a source to share
Write a service started at boot time and let it create some shared memory. This shared memory can then be filled by process A, and process B can read it afterwards.
If your system is rebooted, the shared memory is gone and you have a new, new piece of shared memory. Make sure your service "initializes" the shared memory correctly.
a source to share
Is there a reason the data needs to be memory-resident when ProcessA exits rather than being stored somewhere on disk? I am asking how do you specify the temporary files that should work if ProcessA does not work in an unexpected way.
Depending on your needs, a nice way to provide generic / swift / atomic data is via ESENT API .
a source to share
Try the following. I can't say I know this works, but it seems reasonable.
Create a shared memory file in the global namespace using OpenFileMapping . Then call Duplicatehandle and for the target process handler use some process that will live longer than process A. You might be able to add the handle to winlogon.exe This should stop the destruction of shared memory when process A. exits Then in process B you can find the file shared memory.
a source to share
Well, I managed to create a MailSlot in a Process that doesn't exit, the other two Processes can read and write to the MailSlot server as clients ... Even if the clients exit, Mailslot will still have data ... the MailSlot server allows me to store data in volatile memory since the MailSlot server process has already exited .. or the OS crashes .. and disappears when the OS reboots ... Thanks for all the ideas and help .... :)
a source to share