I am fairly new to Win32 programming. I want to create a shared memory between two processes. I already have created shared memory using the Memory Mapping function.
My struct would look this this:
struct sharedMemory
{
int ans1;
int ans2;
BOOLEAN flag1;
};
Now I am able to access this shared memory from different processes, but I am confused on how to apply lock to this shared memory so that only 1 process is able to access the struct member variable.
By providing a mutex name when calling CreateMutex
, you'll make the mutex visible from other processes.
If another process passes the same name to the CreateMutex
, it will get the existing mutex (instead of creating a new one), which can then be used for inter-process synchronization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With