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

时间:2010年04月21日 点击:733

方法17 :ShellProc Function

The ShellProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The function receives notifications of Shell events from the system.

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

ShellProc钩子子程是同SetWindowsHookEx一起使用的、应用程序定义的或者库定义的回调函数。该方法接收来自系统的加壳事件通知。HOOKPROC类型定义了指向该方法的指针。ShellProc应用程序定义的或者库定义的方法的名字。

Syntax 语法

LRESULT CALLBACK ShellProc(     

    int nCode,

    WPARAM wParam,

    LPARAM lParam

);

Parameters参数

nCode [in] Specifies the hook code. 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方法返回的返回值。该参数可以是下列值:

1HSHELL_ACCESSIBILITYSTATE

Windows 2000/XP: The accessibility state has changed. 可访问性已经改2HSHELL_ACTIVATESHELLWINDOW

The shell should activate its main window. 外壳应该激活它的主窗口。3HSHELL_APPCOMMAND

Windows 2000/XP: The user completed an input event (for example, pressed an application command button on the mouse or an application command key on the keyboard), and the application did not handle the WM_APPCOMMAND message generated by that input.

用户完成一个输入事件(例如,按下应用程序鼠标上的命令按钮或者键盘上的命令键),应用程序没有处理由该输入产生的WM_APPCOMMAND 消息。

If the Shell procedure handles the WM_COMMAND message, it should not call CallNextHookEx. See the Return Value section for more information.

如果Shell子程获得了WM_COMMAND消息的句柄,不应该调用CallNextHookEx

4HSHELL_GETMINRECT

A window is being minimized or maximized. The system needs the coordinates of the minimized rectangle for the window. 窗口正在被最小化或者最大化。系统需要窗体的最小矩形框的坐标。

5HSHELL_LANGUAGE

Keyboard language was changed or a new keyboard layout was loaded.键盘语言被改变了或者新的键盘布局被加载了。

6HSHELL_REDRAW

The title of a window in the task bar has been redrawn. 任务栏中的窗口标题被重绘了。

7HSHELL_TASKMAN

The user has selected the task list. A shell application that provides a task list should return TRUE to prevent Microsoft Windows from starting its task list. 用户选择了任务列表。提供了任务列表的加壳应用程序应该返回TRUE,来阻止windows启动任务列表。

8HSHELL_WINDOWACTIVATED

The activation has changed to a different top-level, unowned window. 激活动作变成了不同的top-levelunowned 的窗口。(即,激活了不同的不明窗口,使其处于最上层。)

9HSHELL_WINDOWCREATED

A top-level, unowned window has been created. The window exists when the system calls this hook. 顶层的、不受控制的窗体已经被创建。当系统调用该钩子时,窗口存在。

10HSHELL_WINDOWDESTROYED

A top-level, unowned window is about to be destroyed. The window still exists when the system calls this hook. 顶层的、不受控制的窗体即将被销毁。当系统调用该钩子的时候该窗体依然存在。

11HSHELL_WINDOWREPLACED

Windows XP: A top-level window is being replaced. The window exists when the system calls this hook. Windows XP环境下,顶层的窗体正在被替换掉。当系统调用该钩子时,窗口存在。

wParam

[in] The value depends on the value of the nCode parameter, as shown in the following table.该值取决于参数 nCode 如下表所示。

nCode

wParam

HSHELL_ACCESSIBILITYSTATE

Windows 2000/XP: Indicates which accessibility feature has changed state. This value is one of the following: ACCESS_FILTERKEYS,ACCESS_MOUSEKEYS, or ACCESS_STICKYKEYS.

Windows XP 环境下:指示哪种访问特征已经被改变了状态。值可以是下列之一:ACCESS_FILTERKEYS,ACCESS_MOUSEKEYS, ACCESS_STICKYKEYS.

HSHELL_APPCOMMAND

Windows 2000/XP: Where the WM_APPCOMMAND message was originally sent; for example, the handle to a window.

WM_APPCOMMAND消息最初发出的位置,例如,窗口的句柄。

HSHELL_GETMINRECT

Handle to the minimized or maximized window.最小化或者最大化的窗体的句柄。

HSHELL_LANGUAGE

Handle to the window.窗口句柄。

HSHELL_REDRAW

Handle to the redrawn window.重化窗口句柄。

HSHELL_WINDOWACTIVATED

Handle to the activated window.活动窗口句柄。

HSHELL_WINDOWCREATED

Handle to the created window.被创建的窗口的句柄。

HSHELL_WINDOWDESTROYED

Handle to the destroyed window.被销毁的窗口的句柄。

HSHELL_WINDOWREPLACED

Windows XP: Handle to the window being replaced.即将被替换的窗体的句柄。

lParam

[in] The value depends on the value of the nCode parameter, as shown in the following table. 该值取决于参数nCode如下表所示。

nCode

lParam

HSHELL_APPCOMMAND

Windows 2000/XP:GET_APPCOMMAND_LPARAM(lParam) is the application command corresponding to the input event.

GET_APPCOMMAND_LPARAM是对输入事件做出响应的应用程序命令。

GET_DEVICE_LPARAM(lParam) indicates what generated the input event; for example, the mouse or keyboard.

GET_DEVICE_LPARAM指示是什么生成了输入事件。例如,鼠标或者键盘。

GET_FLAGS_LPARAM(lParam) depends on the value of cmd in WM_APPCOMMAND. For example, it might indicate which virtual keys were held down when the WM_APPCOMMAND message was originally sent. GET_FLAGS_LPARAM(lParam)依赖于 WM_APPCOMMANDCMD的值。例如,可以指示当WM_APPCOMMAND消息被发出的时候,哪个虚拟键被按下。

 

HSHELL_GETMINRECT

Pointer to a RECT structure.    RECT结构的指针

HSHELL_LANGUAGE

Handle to a keyboard layout.   键盘布局的句柄。

HSHELL_REDRAW

The value is TRUE if the window is flashing, or FALSE otherwise.  如果窗口正在闪烁(重绘过程中),该值为true,其他为false

HSHELL_WINDOWACTIVATED

The value is TRUE if the window is in full-screen mode, or FALSE otherwise. 如果窗体处于全屏模式,该值是true,否则为false

HSHELL_WINDOWREPLACED

Windows XP: Handle to the new window.新窗体的句柄。

Return Value返回值

The return value should be zero unless the value of nCode is HSHELL_APPCOMMAND and the shell procedure handles the WM_COMMAND message. In this case, the return should be nonzero.

如果nCode的值是HSHELL_APPCOMMANDshell子程句柄指向WM_COMMAND 消息,在这种情况下,返回值是非0。其他情况下,返回值是0

Remarks备注

Install this hook procedure by specifying the WH_SHELL hook type and a pointer to the hook procedure in a call to the SetWindowsHookEx function. 通过指定WH_SHELL 钩子类型以及在SetWindowsHookEx的方法中的指向钩子子程的指针来安装该钩子子程。

Helios  2007-5-31

 

赞助商链接

热门内容

相关内容

联系我们

联系方式