PostMessage SendMessage SendNotifyMesage PostThreadMessage

本文详细介绍了Windows环境下进程和线程间的消息传递函数,包括PostMessage、SendMessage、SendNotifyMessage及PostThreadMessage的功能与用法,并解释了同步与异步消息传递的区别。

进程,线程间消息函数。

Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

BOOL WINAPI PostMessage(
  _In_opt_  HWND hWnd,
  _In_      UINT Msg,
  _In_      WPARAM wParam,
  _In_      LPARAM lParam

);

Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

LRESULT WINAPI SendMessage(
  _In_  HWND hWnd,
  _In_  UINT Msg,
  _In_  WPARAM wParam,
  _In_  LPARAM lParam
);

Sends the specified message to a window or windows. If the window was created by the calling thread, SendNotifyMessage calls the window procedure for the window and does not return until the window procedure has processed the message. If the window was created by a different thread, SendNotifyMessage passes the message to the window procedure and returns immediately; it does not wait for the window procedure to finish processing the message.

BOOL WINAPI SendNotifyMessage(
  _In_  HWND hWnd,
  _In_  UINT Msg,
  _In_  WPARAM wParam,
  _In_  LPARAM lParam
);

Posts a message to the message queue of the specified thread. It returns without waiting for the thread to process the message.

BOOL WINAPI PostThreadMessage(
  _In_  DWORD idThread,
  _In_  UINT Msg,
  _In_  WPARAM wParam,
  _In_  LPARAM lParam
);
附加参数可以使用wParam,lParam,一般通过指针传递大量的参数。

send属于同步,一般不会有什么问题。

post属于异步,在发送方动态申请内存,接收方使用时候释放内存。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值