BOOL UnhookWindowsHookEx(hhook) | |||||
HHOOK hhook; | /* handle of hook function to remove | */ |
The UnhookWindowsHookEx function removes an application-defined hook function from a chain of hook functions. A hook function processes events before they are sent to an application's message loop in the WinMain function.
hhook
Identifies the hook function to be removed. This is the value returned by the SetWindowsHookEx function when the hook was installed.
The return value is nonzero if the function is successful. It is zero if the hook cannot be found.
The UnhookWindowsHookEx function must be used in combination with the SetWindowsHookEx function.
The following example uses the UnhookWindowsHookEx function to remove a message filter that was used to provide context-sensitive help for a dialog box:
DLGPROC lpfnAboutProc;
HOOKPROC lpfnFilterProc;
HHOOK hhook;
case IDM_ABOUT:
lpfnAboutProc = (DLGPROC) MakeProcInstance(About, hinst);
lpfnFilterProc = (HOOKPROC) MakeProcInstance(FilterFunc, hinst);
hhook = SetWindowsHookEx(WH_MSGFILTER, lpfnFilterProc,
hinst, (HTASK) NULL);
DialogBox(hinst, "AboutBox", hwnd, lpfnAboutProc);
UnhookWindowsHookEx(hhook);
FreeProcInstance((FARPROC) lpfnFilterProc);
FreeProcInstance((FARPROC) lpfnAboutProc);
break;