简体   繁体   中英

sharing memory between two applications

I have two different windows applications (two different people writing the code). One is Written in C++ and another one is in C#. I need some way how to share data in RAM between them. One must writes data and another one just reads the written data. What should I use to make it most effective and fast? Thanks.

You can use Memory Mapped Files .

Here is an article describing how to use them.

使用Windows 文件映射对象 ,它允许您在进程之间共享内存。

You can use Named Pipes .

A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously.

Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes.

I recommend you to redesign it to let it use communication based on messages. It is more robust and much easier to use in .NET with its automatic memory management (when compared to shared memory). Although slower.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM