RSS订阅 | 匿名投稿
您的位置:网站首页 > 键盘 > 正文

delphi 全局钩子锁定键盘

作者:admin 来源:未知 日期:2010/5/9 0:21:38 人气: 标签:

//可以锁所有键盘按键和任意组合键,但对于ALT+TAB,CTRL+ALT+DEL无效!

//DLL代码如下

Library KillKB;

uses Wintypes, WinProcs;

Var
oldHook: HHook;

function KBHooKProc(code: Integer; wParam: WPARAM;lParam: LPARAM):LRESULT;stdcall; export;
Begin
If code < 0 Then
Result := CallNextHookEx( oldHook, code, wparam, lparam )
Else
Result := 1;
end;

function DisableKeyboard: Boolean; export;
Begin
oldHook := SetWindowsHookEx(WH_KEYBOARD,KBHooKProc,HInstance, 0 );
DisableKeyboard := oldHook <> 0;
End;

procedure EnableKeyboard; export;
Begin
If oldHook <> 0 Then Begin
UnhookWindowshookEx( oldHook );
oldHook := 0;
End;
End;

exports
DisableKeyboard,
EnableKeyboard;

Begin
oldHook := 0;
End.

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: