C Question

Creating Shared-Memory for two different processes

So, I'm trying to create a shared-memory segment in a C program, so I can for example write a simple character in it, and read that character from another C program.

I've been trying to use

but I do believe this only works for this program's own

Is there another function to do this same thing, but in the
memory? Maybe through an hexadecimal value? Or am I wrong and these functions actually reserve memory visible to all processes?

Thanks in advance.

-I'm using windows 8.
-Language is not restricted to C, can be any other language.

Answer Source

AFAIK Windows has no easy-to-use C interface to low level IPC like you're asking for. Not anything like /dev/shm, pipes or whatever parallel one might draw to *nix IPC.

I'd look into using a framework/library such as ZeroMQ, RabbitMQ or whatever is fancy these days. At least if you want to code up against a modern C API. I don't think you have anything better than Win32API to work with natively, but correct me if I'm wrong.

A google search for "C windows IPC" reveals a handful of frameworks. Don't know which to recommend, but you should research what Inter Process Communication options you have :)


If language doesn't matter and you know C# and have access to Visual Studio (I think you can download Express Edition for free?) go for an example written for the Windows Communication Framework. It's high level, has some cross language/platform support (not for all features) and is EASY to get going. The documentation has lots of examples. That's the easiest IPC I know of on Windows :)

Maybe this answer can help: wcf named pipe minimal example