sharing memory between two applications

心已入冬 提交于 2019-11-26 06:47:13

问题


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.


回答1:


You can use Memory Mapped Files.

Here is an article describing how to use them.




回答2:


Use a Windows File Mapping Object which allows you to share memory between processes.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/7894224/sharing-memory-between-two-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!