钩子初接触(二十三)

方法18 :SysMsgProc Function

The SysMsgProc hook procedure is a library-defined callback function used with the SetWindowsHookEx function. The system calls this function after an input event occurs in a dialog box, message box, menu, or scroll bar, but before the message generated by the input event is processed. The function can monitor messages for any dialog box, message box, menu, or scroll bar in the system.

 SysMsgProc钩子子程是同SetWindowsHookEx一起使用的在库中定义的回调函数。在对话框、消息框、菜单、滚动条中所属的输入事件发生后,在这些消息被系统处理之前,系统调用该方法。该方法能够为系统中任何对话框、消息框、菜单、滚动条监视消息。

The HOOKPROC type defines a pointer to this callback function. SysMsgProc is a placeholder for the application-defined or library-defined function name.

HOOKPROC类型定义了回调函数的指针,SysMsgProc是应用程序定义的或者库定义的方法的名字。

Syntax语法

LRESULT CALLBACK SysMsgProc(      

    int nCode,
    WPARAM wParam,
  
  
    LPARAM lParam
  
  
);
  
  

Parameters参数

nCode

[in] Specifies the type of input event that generated the message. If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx. This parameter can be one of the following values. 指定生成该消息的输入事件的类型。如果nCode小于0,钩子子程必须将消息传递给CallNextHookEx方法,自己不进行进一步的处理,并且应该返回由CallNextHookEx方法返回的返回值。。该参数可以是以下值之一:

1MSGF_DIALOGBOX The input event occurred in a message box or dialog box.  输入事件在消息框或者对话框中发生。

2MSGF_MENU The input event occurred in a menu.输入事件在菜单中发生。

3MSGF_SCROLLBAR The input event occurred in a scroll bar.输入事件在滚动条中发生。

wParam This parameter is not used. 该参数未使用。

lParam [in] Pointer to an MSG message structure.指向MSG消息结构的指针。

Return Value 返回值

If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.

If nCode is greater than or equal to zero, and the hook procedure did not process the message, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_SYSMSGFILTER hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure processed the message, it may return a nonzero value to prevent the system from passing the message to the target window procedure.

如果nCode小于0,钩子子程必须返回由CallNextHookEx方法返回的返回值。如果nCode大于等于0,并且钩子子程还没有处理该消息,强烈要求调用CallNextHookEx方法并返回由它返回的返回值。否则,其他已经安装了WH_SYSMSGFILTER钩子的应用程序将接收不到钩子通知,可能导致行为错误。如果钩子子程已经处理了该消息,应该返回非0 值,来阻止系统将消息传递给目标窗体程序。

Remarks备注

An application installs the hook procedure by specifying the WH_SYSMSGFILTER hook type and a pointer to the hook procedure in a call to the SetWindowsHookEx function.

应用程序安装该钩子通过:指定WH_SYSMSGFILTER钩子类型;指定在调用SetWindowsHookEx方法的指向钩子子程的指针。

Helios  2007-5-31

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值