📄 apicallbackprocs.bas
字号:
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_MSGFILTER), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKMESSAGEFILTERPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKMESSAGEFILTERPROC = lret
End If
End Function
'\\ [VB_HOOKSHELLPROC]----------------------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ ----------------------------------------------------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------------------------------------------------
Public Function VB_HOOKSHELLPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKSHELLPROC = CallNextHookEx(Eventhandler.HookIdByType(WH_SHELL), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam
Params(3) = lParam
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
Eventhandler.TriggerEvent HOOKPROC_SHELL, Params()
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_SHELL), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKSHELLPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKSHELLPROC = lret
End If
End Function
'\\ [VB_HOOKSYSMESSAGEFILTERPROC]----------------------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ ----------------------------------------------------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------------------------------------------------
Public Function VB_HOOKSYSMESSAGEFILTERPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKSYSMESSAGEFILTERPROC = CallNextHookEx(Eventhandler.HookIdByType(WH_SYSMSGFILTER), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam
Params(3) = lParam
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
Eventhandler.TriggerEvent HOOKPROC_SYSMESSAGEFILTER, Params()
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_SYSMSGFILTER), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKSYSMESSAGEFILTERPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKSYSMESSAGEFILTERPROC = lret
End If
End Function
'\\ [VB_HOOKLOWLEVELKEYBOARDPROC]----------------------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ ----------------------------------------------------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------------------------------------------------
Public Function VB_HOOKLOWLEVELKEYBOARDPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKLOWLEVELKEYBOARDPROC = CallNextHookEx(Eventhandler.HookIdByType(WH_KEYBOARD_LL), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam 'virtual key (WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP)
Params(3) = lParam 'pointer to a KBDLLHOOKSTRUCT object
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
Eventhandler.TriggerEvent HOOKPROC_KEYBOARD_LL, Params()
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_KEYBOARD_LL), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKLOWLEVELKEYBOARDPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKLOWLEVELKEYBOARDPROC = lret
End If
End Function
'\\ [VB_HOOKKEYBOARDPROC]----------------------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ ----------------------------------------------------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------------------------------------------------
Public Function VB_HOOKKEYBOARDPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKKEYBOARDPROC = CallNextHookEx(Eventhandler.HookIdByType(WH_KEYBOARD), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam
Params(3) = lParam
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
Eventhandler.TriggerEvent HOOKPROC_KEYBOARD, Params()
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_KEYBOARD), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKKEYBOARDPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKKEYBOARDPROC = lret
End If
End Function
'\\ [VB_HOOKHARDWAREPROC]----------------------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ ----------------------------------------------------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------------------------------------------------
Public Function VB_HOOKHARDWAREPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKHARDWAREPROC = CallNextHookEx(Eventhandler.HookIdByType(WH_HARDWARE), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam
Params(3) = lParam
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
Eventhandler.TriggerEvent HOOKPROC_HARDWARE, Params()
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(WH_HARDWARE), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKHARDWAREPROC ", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKHARDWAREPROC = lret
End If
End Function
'\\ [VB_HookProc]----------------------------------------------------------------------------------
'\\ typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
'\\ code - type of hook,
'\\ Wparam, Lparam - message specific
'\\ lMsgRet = The message to pass to the calling code
'\\ NOTE:
'\\ This code has been kept for backwards compatibility only.
'\\ You should use the specific CBTHookProc, ShellHookProc etc...
'\\ ----------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------
Public Function VB_HOOKPROC(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim Params() As Variant
Dim lret As Long
Dim lMsgRet As Long
'\\ Note: If the code passed in is less than zero, it must be passed direct to the next hook proc
If Code < 0 Then
VB_HOOKPROC = CallNextHookEx(Eventhandler.HookIdByType(Eventhandler.CurrentHookType), Code, wParam, lParam)
End If
'\\ 1 - Pack the param array.....
ReDim Params(1 To 4) As Variant
Params(1) = Code
Params(2) = wParam
Params(3) = lParam
Params(4) = lMsgRet
'\\ 2 - Call the event firer....
If Not Eventhandler Is Nothing Then
If Eventhandler.CurrentHookType = WH_MOUSE Then
Eventhandler.TriggerEvent HOOKPROC_MOUSE, Params()
ElseIf Eventhandler.CurrentHookType = WH_MOUSE_LL Then
Eventhandler.TriggerEvent HOOKPROC_MOUSE_LL, Params()
Else
Eventhandler.TriggerEvent HOOKPROC, Params()
End If
lMsgRet = Params(4)
End If
'\\ 3 - Pass this message on to the next hook proc in the chain (if any)
lret = CallNextHookEx(Eventhandler.HookIdByType(Eventhandler.CurrentHookType), Code, wParam, lParam)
If Err.LastDllError > 0 Then
Call ReportError(Err.LastDllError, "VB_HOOKPROC", GetLastSystemError)
End If
'\\ If the message isn't cancelled, return the next hook's message...
If Not (lMsgRet) Then
'\\ Return value to calling code....
VB_HOOKPROC = lret
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -