Sending/Receiving a string through PostMessage

≡放荡痞女 提交于 2019-12-05 04:25:34

When using Windows messages, you should use WM_COPYDATA to transfer string data between processes. If you use custom message IDs then the string data will not be marshalled between the two distinct process address spaces.

And this is why your current code fails. The receiving process is passed in lParam a pointer to memory in the address space of the calling processes. And of course that is meaningless in the other process.

Whilst there are other ways to marshal data like this between processes with Windows messages, WM_COPYDATA is by far the simplest. If your requirement becomes much more complex then you may need to consider a more comprehensive IPC approach than Windows messages.

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