Windows Dev Center

Expand Minimize

RegisterShellHookWindow function

[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 WINAPI RegisterShellHookWindow(
  _In_ HWND hWnd
);

Parameters

hWnd [in]

Type: HWND

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

Return value

Type:

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.

wParamlParam
HSHELL_GETMINRECTA pointer to a SHELLHOOKINFO structure.
HSHELL_WINDOWACTIVATEDA handle to the activated window.
HSHELL_RUDEAPPACTIVATEDA handle to the activated window.
HSHELL_WINDOWREPLACINGA handle to the window replacing the top-level window.
HSHELL_WINDOWREPLACEDA handle to the window being replaced.
HSHELL_WINDOWCREATEDA handle to the window being created.
HSHELL_WINDOWDESTROYEDA handle to the top-level window being destroyed.
HSHELL_ACTIVATESHELLWINDOWNot used.
HSHELL_TASKMANCan be ignored.
HSHELL_REDRAWA handle to the window that needs to be redrawn.
HSHELL_FLASHA handle to the window that needs to be flashed.
HSHELL_ENDTASKA handle to the window that should be forced to exit.
HSHELL_APPCOMMANDThe 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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
DeregisterShellHookWindow
SetWindowsHookEx
WindowProc
ShellProc
Conceptual
Windows
Using Messages and Message Queues
Other Resources
WinEvents

 

 

Community Additions

ADD
Show:
© 2015 Microsoft