HOOK的问题,请教各位大哥(50分)

  • 主题发起人 主题发起人 liujunguo
  • 开始时间 开始时间
L

liujunguo

Unregistered / Unconfirmed
GUEST, unregistred user!
library HKTest;

uses
HKProc in 'HKProc.pas';

exports
EnableHotKeyHook;
DiableHotKeyHook;

begin
hNextHookProc:=0;
ProcSaveExit:=ExitProc;
ExitProc:=@HotKeyHookExit;
end.
*****************************
unit HKProc;

interface

uses
Windows,Messages;

var
hNextHookProc:HHook;
ProcSaveExit:Pointer;

function KeyboardHookHandler(iCode:Integer;wParam:WPARAM;
lParam:LPARAM):LRESULT;stdcall;export;
function EnableHotKeyHook:BOOL;export;
function DisableHotKeyHook:BOOL;export
procedure HotKeyHookExit;far;

implementation

function KeyboardHookHandle(iCode:Integer;wParam:WPARAM;
lParam:LPARAM):LRESULT;stdcall;export;
const
_KeyPressMask=$80000000;
begin
Result:=0;
if iCode<0 then
begin
Result:=CallNextHookEx(hNextHookProc,iCode,wParam,lParam);
exit;
end;
if ((lParam and _KeyPressMask)=0) and
(GetKeyState(vk_Control)<0) and (wParam=Ord('B')) then
begin
Result:=1;
WinExec('Notepad.exe',sw_Normal);
end;
end;


function EnableHotKeyHook:BOOL;export;
begin
Result:=False;
if hNextHookProc<>0 then Exit;
hNextHookProc:=SetWindowsHookEx(WH_KEYBOARD,KeyboardHookHandler,
HInstance,0);
Result:=hNextHookproc<>0;
end;


function DisableHotKeyHook:BOOL;export;
begin
if hNextHookProc<>0 then
begin
UnHookWindowsHookEx(hNextHookProc);
hNextHookProc:=0;
MessageBeep(0);
MessageBeep(0);
end;
Result:=hNextHookProc=0;
end;


procedure HotKeyHookExit;
begin
if hNextHookProc<>0 then
DisableHotKeyHook;
ExitProc:=ProcSaveExit;
end;

end.
*************
编译时,出现错误提示:
[Error] HKProc.pas(13):
Unsatisfied forward or external declaration: 'KeyboardHookHandler'
是什么原因?如何处理?
 
KeyboardHookHandler<>KeyboardHookHandle
 
接受答案了.
 
后退
顶部