当前位置: 动力学知识库 > 问答 > 编程问答 >

winapi - WM_COPYDATA, PostThreadMessage, and Error 1159

问题描述:

I am trying to send data from one app to another using WM_COPYDATA. Both apps are console and have no window. I can send user messages just fine. When I try to send WM_COPYDATA, and setup the data structure or not, I get error 1159, which basically says I have to send using a synchronous message call... yet there is no SendThreadMessage.

It seems this is a oversight in the api or docs? There seems to be no way to use WM_COPYDATA using only threads without windows?

网友答案:

WM_COPYDATA can only be sent and cannot be posted. Because the payload is marshaled between processes, temporary data structures are created to support that marshaling. They need to be destroyed when the message processing is complete. That implies that the message must be delivered synchronously.

All of this means that you cannot use PostThreadMessage. Instead you will need to create a window to act as the recipient of such messages. Note that this window can be a message-only window and does not need to be visible.

分享给朋友:
您可能感兴趣的文章:
随机阅读: