============直接把这部分拷贝到txt,然后改扩展名为dpr,之后编译得到dll<br>library DllP;<br> uses windows;<br><br>var<br> HookH:HHook; //钩子句柄<br>function keyhook(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;<br>begin<br> if wParam=vk_Space then //如果是空格<br> Result:=CallNextHookEx(HookH,code,Wparam,lParam)<br> else<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><br> HookOn,HookOff;<br><br>begin<br>end.<br>====然后在我们的程序中先声明 然后调用 hookon 挂钩就可以了 想要钩子失效就调用hookoff<br>procedure HookOn ; stdcall; external '您那边编译得到的dll文件名.dll';<br>procedure HookOff ; stdcall; external '您那边编译得到的dll文件名.dll'; <br><br> hookon; //挂键盘钩子 <br>