|
|
Delphi Tips & Tricks | Tips & Tricks | Bug List | Cool Delphi Sites | Enabling & Disabling the Keyboard 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.
Note: There are a few key combinations that are not passed on to apps at all so they
cannot be trapped by a hook. Ctrl-Alt-Del may be one of them but I'm not sure. Just try to
see if you can get the blue screen when you have disabled the keyboard via the DLL.
Other dubious candiates are Alt-Tab and Ctrl-Esc. | Borland Delphi | About the Authors | Home |
Copyright © 1996 Asylum Software Pvt. Ltd. This is an ASPL production. |