首页  编辑  

禁止和允许键盘按键

Tags: /超级猛料/Hardware.硬件相关/键盘和鼠标/   Date Created:

禁止和允许键盘,需要一个DLL来做到这一点:

Library KillKB;

Uses Wintypes, WinProcs

{$IFNDEF VER80}

 ,Win31

{$ENDIF}

 ;

Var

 oldHook: HHook;

Function KbHook( code: Integer; wparam: Word; lparam: LongInt ): LongInt;

 export;

Begin

 If code < 0 Then

   KbHook := CallNextHookEx( oldHook, code, wparam, lparam )

 Else

   KbHook := 1;

End; { KbHook }

Function DisableKeyboard: Boolean; export;

Begin

 oldHook := SetWindowsHookEx( WH_KEYBOARD, KbHook, HInstance, 0 );

 DisableKeyboard := oldHook <> 0;

End;

Procedure EnableKeyboard; export;

Begin

 If oldHook <> 0 Then Begin

   UnhookWindowshookEx( oldHook );

   oldHook := 0;

 End; { If }

End;

exports

DisableKeyboard index 1,

EnableKeyboard index 2;

Begin

 oldHook := 0;

End.

有一些组合键不能屏蔽掉,例如Ctrl+Alt+Del!使用这个有可能导致蓝屏~~~~~~~~:(,你自己看着办吧。