RegisterShellHookWindow on MSDN says:
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 identifiers (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.
See my sample here:
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0500
// our window class name
#define MY_CLASS TEXT("MyShellHookWndClass")
#include <windows.h>
// callback function that will receive the shell
// hook messages
LRESULT CALLBACK _MyWndProc(HWND, UINT, WPARAM, LPARAM);
// see remarks section of RegisterShellHookWindow
UINT g_msg;
int __stdcall WinMain(IN HINSTANCE hInstance, IN HINSTANCE
hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd )
{
HWND hWnd;
MSG msg;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)_MyWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = MY_CLASS;
wcex.hIconSm = NULL;
RegisterClassEx(&wcex);
// create a dummy window to receive messages
hWnd = CreateWindow(MY_CLASS, NULL, 0, 0, 0, 0, 0,
NULL, NULL, hInstance, NULL);
// get the message number we need to fetch
g_msg = RegisterWindowMessage(TEXT("SHELLHOOK"));
if (!hWnd || !RegisterShellHookWindow(hWnd))
{
// either window creation or
// hook registration failed
MessageBox(NULL, TEXT("Unable to install shell hook."),
TEXT("Error"),
MB_OK | MB_ICONERROR);
return 1;
}
while(GetMessage(&msg, hWnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK _MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
// is this the shell hook message?
if (uMsg == g_msg)
{
// so which one is it?
switch(wParam)
{
case HSHELL_GETMINRECT:
LPSHELLHOOKINFO pshi;
pshi = (LPSHELLHOOKINFO)lParam;
pshi->rc;
break;
// you can handle other shell hook messages here
default:
break; // may be, this could be return 0?
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
i hope it helps.