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; 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 | The HWND handle of the activated window. |
| HSHELL_RUDEAPPACTIVATED | The HWND handle of the activated window. |
| HSHELL_WINDOWREPLACING | The HWND handle of the window replacing the top-level window. |
| HSHELL_WINDOWREPLACED | The HWND handle of the window being replaced. |
| HSHELL_WINDOWCREATED | The HWND handle of the window being created. |
| HSHELL_WINDOWDESTROYED | The HWND handle of the top-level window being destroyed. |
| HSHELL_ACTIVATESHELLWINDOW | Not used. |
| HSHELL_TASKMAN | Can be ignored. |
| HSHELL_REDRAW | The HWND handle of the window that needs to be redrawn. |
| HSHELL_FLASH | The HWND handle of the window that needs to be flashed. |
| HSHELL_ENDTASK | The HWND handle of 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. |
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 Version | user32.dll |
|---|
| Header | Declared in Winuser.h, include Windows.h |
|---|
| Import library | User32.lib |
|---|
| Minimum operating systems |
Windows 2000 |
|---|
| Unicode | Implemented as
ANSI and Unicode versions. |
|---|
See Also