SendMessage和PostMessage及Windows消息机制简介

本文简要介绍了Windows消息机制中的SendMessage函数,它将消息发送到窗口并等待处理完成。SendMessage会调用窗口过程,直到消息被处理。
摘要由CSDN通过智能技术生成

SendMessage:

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

SendMessage函数将指定的消息发到窗口。它调用特定窗口的窗口处理函数,并且不会立即返回,直到窗口处理函数处理了这个消息。SendMessage只是调用我们的消息处理函数

LRESULT WINAPI SendMessage(

  _In_  HWND hWnd,
  _In_  UINT Msg,
  _In_  WPARAM wParam,
  _In_  LPARAM lParam
);

Parameters

hWnd [in]

Type: HWND

A handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST ((HWND)0xffff), the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.窗口程序将接收消息的窗口的句柄。如果此参数为HWND_BROADCAST,则消息将被发送到系统中所有顶层窗口,包括无效或不可见的非自身拥有的窗口、被覆盖的窗口和弹出式窗口,但消息不被发送到子窗口。

Message sending is subject to UIPI. The thread of a process can send messages only to message queues of threads in processes of lesser or equal integrity level.消息发送属于UIPI(User Interface Privilege Isolation(用户界面特权隔离)

UIPI保护了高权限进程的界面和用户对象(User Object)不受到低权限恶意进程的更改。通常,一个进程权限的高低取决于它的Integrity Level (IL)。)要更加详细了解UIPI可去http://wenku.baidu.com/link?url=YpkH1-XZzr435JrgrZyDcP4kfNIJJYKSLN7drGIr9OgiPfL2p1bN83Ue-AakfU_fB1hB-w8WK52c2xnOutTWzE2WfDVbTtE2vvHhVV2PbFu 或者http://blog.csdn.net/chris820313/article/details/6706034)一个进程的线程能发送消息到进程中唯一的线程的消息队列

Msg [in]

Type: UINT

The message to be sent.被发送的消息。

For lists of the system-provided messages, see System-Defined Messages.系统提供的消息列表可参见System-Defined Messages

wParam [in]

Type: WPARAM

Additional message-specific information.指定附加的消息特定的信息。

lParam [in]

Type: LPARAM

Additional message-specific information.

Return value

Type:

Type: LRESULT

The return value specifies the result of the message processing; it depends on the message sent.

返回值指定消息处理的结果,依赖于所发送的消息。

PostMessage:

The PostMessage function 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.
PostMessage函数将一个消息放入与创建这个窗口的消息队列相关的线程中,并立刻返回不等待线程处理消息。PostMessage只是将消息放到消息队列中

Parameters

hWnd [in, optional]

Type: HWND

A handle to the window whose window procedure is to receive the message. The following values have special meanings.

其窗口程序接收消息的窗口的句柄。以下值具有特殊意义:

Value
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值