RegisterShellHookWindow function (winuser.h)

[This function is not intended for general use. It may be altered or unavailable in subsequent versions of Windows.]

Registers a specified Shell window to receive certain messages for events or notifications that are useful to Shell applications.

The event messages received are only those sent to the Shell window associated with the specified window's desktop. Many of the messages are the same as those that can be received after calling the SetWindowsHookEx function and specifying WH_SHELL for the hook type. The difference with RegisterShellHookWindow is that the messages are received through the specified window's WindowProc and not through a call back procedure.

Syntax

BOOL RegisterShellHookWindow(
  [in] HWND hwnd
);

Parameters

[in] hwnd

Type: HWND

A handle to the window to register for Shell hook messages.

Return value

Type: BOOL

TRUE if the function succeeds; otherwise, FALSE.

Remarks

As with normal window messages, the second parameter of the window procedure identifies the message as a WM_SHELLHOOKMESSAGE. However, for these Shell hook messages, the message value is not a pre-defined constant like other message IDs such as WM_COMMAND. The value must be obtained dynamically using a call to RegisterWindowMessage as shown here:

RegisterWindowMessage(TEXT("SHELLHOOK"));

This precludes handling these messages using a traditional switch statement which requires ID values that are known at compile time. For handling Shell hook messages, the normal practice is to code an If statement in the default section of your switch statement and then handle the message if the value of the message ID is the same as the value obtained from the RegisterWindowMessage call.

The following table describes the wParam and lParam parameter values passed to the window procedure for the Shell hook messages.

wParam lParam
HSHELL_GETMINRECT A pointer to a SHELLHOOKINFO structure.
HSHELL_WINDOWACTIVATED A handle to the activated window.
HSHELL_RUDEAPPACTIVATED A handle to the activated window.
HSHELL_WINDOWREPLACING A handle to the window replacing the top-level window.
HSHELL_WINDOWREPLACED A handle to the window being replaced.
HSHELL_WINDOWCREATED A handle to the window being created.
HSHELL_WINDOWDESTROYED A handle to the top-level window being destroyed.
HSHELL_ACTIVATESHELLWINDOW Not used.
HSHELL_TASKMAN Can be ignored.
HSHELL_REDRAW A handle to the window that needs to be redrawn.
HSHELL_FLASH A handle to the window that needs to be flashed.
HSHELL_ENDTASK A handle to the window that should be forced to exit.
HSHELL_APPCOMMAND The APPCOMMAND which has been unhandled by the application or other hooks. See WM_APPCOMMAND and use the GET_APPCOMMAND_LPARAM macro to retrieve this parameter.
HSHELL_MONITORCHANGED A handle to the window that moved to a different monitor.
 

This function was not included in the SDK headers and libraries until Windows XP with Service Pack 1 (SP1) and Windows Server 2003. If you do not have a header file and import library for this function, you can call the function using LoadLibrary and GetProcAddress.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

Conceptual

DeregisterShellHookWindow

Other Resources

Reference

SetWindowsHookEx

ShellProc

Using Messages and Message Queues

WinEvents

WindowProc

Windows