1. 程式人生 > >'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.解決辦法

'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.解決辦法

 編寫鉤子程式時,在程式碼:

hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf HookProc, App.hInstance, 0)

處出現錯誤,提示'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.

SetWindowsHookEx的原來的定義如下:

 

於是我新定義了一個和HookProc一樣的函式:

Public Delegate Function HookProcBase(ByVal nCode As Long, ByVal wParam As Long, ByVal lparam As Long) As Long

然後把SetWindowsHookEx改為:

這樣就沒有問題了。