钩子(HOOK)函数教程(二十三)

时间:2010-04-21 点击:统计中..

方法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

赞助商链接

热门内容

相关内容



联系我们

联系方式