普通钩子<br>=============================动态连接库代码<br>library DllP;<br> uses windows;<br> procedure HookOn;stdcall;<br> procedure HookOff;stdcall;<br>var<br> HookH:HHook; //钩子句柄<br>function keyhook(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;<br>begin<br> Result:=1; //强行 屏蔽<br>end;<br><br>procedure HookOn;<br>begin<br> HooKH:=SetWindowsHookEx(WH_KEYBOARD,keyHook,HInstance,0);<br>end;<br><br>procedure HookOff;<br>begin<br> UnHookWindowsHookEx(HookH);<br>end;<br><br>exports<br> HookOn,HookOff;<br>begin<br>end.<br><br>============================在exe中这样:<br>procedure HookOn ; stdcall; external 'DllP.dll';<br>procedure HookOff ; stdcall; external 'DllP.dll'; <br><br> hookon; //挂键盘钩子