Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windowing
Windows
Windows Reference
Functions
 RegisterShellHookWindow Function

  Switch on low bandwidth view
RegisterShellHookWindow Function

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(      
    HWND hWnd );

Parameters

hWnd
[in] Handle to the window to register for Shell hook messages.

Return Value

TRUE if the function succeeds; FALSE if the function fails.

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(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_WINDOWACTIVATEEDThe HWND handle of the activated window.
HSHELL_RUDEAPPACTIVATEEDThe HWND handle of the activated window.
HSHELL_WINDOWREPLACINGThe HWND handle of the window replacing the top-level window.
HSHELL_WINDOWREPLACEDThe HWND handle of the window being replaced.
HSHELL_WINDOWCREATEDThe HWND handle of the window being created.
HSHELL_WINDOWDESTROYEDThe HWND handle of the top-level window being destroyed.
HSHELL_ACTIVATESHELLWINDOWNot used.
HSHELL_TASKMANCan be ignored.
HSHELL_REDRAWThe HWND handle of the window that needs to be redrawn.
HSHELL_FLASHThe HWND handle of the window that needs to be flashed.
HSHELL_ENDTASKThe HWND handle of 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.

Although you can access this function by using LoadLibrary and GetProcAddress combined in Microsoft Windows versions prior to Windows XP, the function is not accessible using the standard Include file and library linkage. The header files included in Windows XP Service Pack 1 (SP1) and Windows Server 2003 document this function and make it accessible using the appropriate Include file and library linkage. However, this function is not intended for general use. It is recommended that you do not use it in new programs because it might be altered or unavailable in subsequent versions of Windows.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 2000
UnicodeImplemented as ANSI and Unicode versions.

See Also

Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker