Sharing memory between two processes (C, Windows)

前端 未结 7 2092
温柔的废话
温柔的废话 2020-11-27 03:06

Since I haven\'t found an answer to the question asked previously here I\'m trying a different approach.

Is there any way to share memory between two processes?

7条回答
  •  面向向阳花
    2020-11-27 03:29

    Memory mapping is the way to go, you don't even need to create a permanent memory space, the memory sector goes out of scope when all the processes sharing it are shutdown. There are other ways too. A quick and dirty way of passing data from one C app to another is just to use the OS. At command line type app1 | app2. This causes app2 to be the output destination of app1 or iow a printf command from app1 would send it to app2 (this is called piping).

提交回复
热议问题