Applies to: desktop apps only
Passes the hook information to the next hook procedure in the current hook chain. A hook procedure can call this function either before or after processing the hook information.
Syntax
LRESULT WINAPI CallNextHookEx( __in_opt HHOOK hhk, __in int nCode, __in WPARAM wParam, __in LPARAM lParam );
Parameters
- hhk [in, optional]
-
Type: HHOOK
This parameter is ignored.
- nCode [in]
-
Type: int
The hook code passed to the current hook procedure. The next hook procedure uses this code to determine how to process the hook information.
- wParam [in]
-
Type: WPARAM
The wParam value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain.
- lParam [in]
-
Type: LPARAM
The lParam value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain.
Return value
Type:
Type: LRESULT
This value is returned by the next hook procedure in the chain. The current hook procedure must also return this value. The meaning of the return value depends on the hook type. For more information, see the descriptions of the individual hook procedures.
Remarks
Hook procedures are installed in chains for particular hook types. CallNextHookEx calls the next hook in the chain.
Calling CallNextHookEx is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Reference
- SetWindowsHookEx
- UnhookWindowsHookEx
- Conceptual
- Hooks
Send comments about this topic to Microsoft
Build date: 2/3/2012
- You DON'T need to pass a handle to the current hook to CallNextHookEx. "This parameter is ignored", as stated above. You can pass NULL for the first argument.
-
But if I call CallNextHookEx function in my LowLevelMouseProc, and there all subsequent hooks will be executed, how the OS will know which hook is guilty of overtime? Is it so that CallNextHookEx somehow mark the last hook executed, to "pass the message to the next hook" "if the hook procedure does not return during this interval"? How does OS measure hook execution time in case when it only place message to the hook thread queue (as in WH_MOUSE_LL)?
- Is it somehow advantageous for me not to call CallNextHookEx to prevent other (sometimes badly performing) hooks to spoil my functionality? Or is it so that in WH_MOUSE_LL case, CallNextHookEx execute time is small and constant, because it only posts a message to the next hook's thread message queue?
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern IntPtr CallNextHookEx(HandleRef hhook, int code, IntPtr wparam, IntPtr lparam);
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> Public Shared Function CallNextHookEx(ByVal hhook As HandleRef, ByVal code As Integer, ByVal wparam As IntPtr, ByVal lparam As IntPtr) As IntPtr
End Function