函式信息
函式功能
將鉤子信息傳遞到當前鉤子鏈中的下一個子程,一個鉤子程式可以調用這個函式之前或之後處理鉤子信息函式原型
LRESULT WINAPI CallNextHookEx( _In_opt_ HHOOK hhk, _In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam);參數
1. hhk[可選]說明:當前鉤子的句柄
類型:HHOOK
此參數將被忽略。
2. nCode [in]
說明:鉤子代碼; 就是給下一個鉤子要交待的
類型:INT
鉤傳遞給當前Hook過程的代碼。下一個鉤子程式使用此代碼,以確定如何處理鉤的信息。
3. wParam[in]
說明:要傳遞的參數; 由鉤子類型決定是什麼參數
類型:WPARAM
wParam參數值傳遞給當前Hook過程。此參數的含義取決於當前的鉤鏈與鉤的類型。
4. lParam[in]
說明:要傳遞的參數; 由鉤子類型決定是什麼參數
類型:LPARAM
lParam的值傳遞給當前Hook過程。此參數的含義取決於當前的鉤鏈與鉤的類型。
返回值
1. 類型:LRESULT2. 返回這個值鏈中的下一個鉤子程式。當前Hook過程也必須返回該值。返回值的含義取決於鉤型。有關詳細信息,請參閱個人鉤子程式的描述
其它資料
速查:Windows 2000及更高版本、Windows Server 2000及更高版本頭檔案:winuser.h
庫檔案:user32.lib;
Unicode:在 Windows NT上實現為 Unicode和 ANSI兩種版本。
C#聲明
[DllImport("user32.dll")]static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam,IntPtr lParam);
// 使用LowLevelKeyboardProc重載(鍵盤鉤子)
[DllImport("user32.dll")]
static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, WM wParam, [In]KBDLLHOOKSTRUCT lParam);
// 使用LowLevelMouseProc重載(滑鼠鉤子)
[DllImport("user32.dll")]
static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, WM wParam, [In]MSLLHOOKSTRUCT lParam);
VB.NET聲明
_Private Shared Function CallNextHookEx(ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
' 使用LowLevelKeyboardProc重載(鍵盤鉤子)
_
Private Shared Function CallNextHookEx(ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As WindowsMessages, <[In]()> ByVal lParam As KBDLLHOOKSTRUCT) As IntPtr
End Function
' 使用LowLevelMouseProc重載(滑鼠鉤子)
_
Private Shared Function CallNextHookEx(ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As WindowsMessages, <[In]()> ByVal lParam As MSLLHOOKSTRUCT) As IntPtr
End Function
VB聲明
Public Declare Function CallNextHookEx Lib "user32" _(ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As WindowsMessages, _
lParam As Any) As Long
' 使用LowLevelKeyboardProc重載(鍵盤鉤子)
Public Declare Function CallNextHookExKbd Lib "user32" Alias "CallNextHookEx" _
(ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As WindowsMessages, _
lParam As KBDLLHOOKSTRUCT) As Long
' 使用LowLevelMouseProc重載(滑鼠鉤子)
Public Declare Function CallNextHookExMse Lib "user32" Alias "CallNextHookEx" _
(ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As WindowsMessages, _
lParam As MSLLHOOKSTRUCT) As Long