Business Directory
Trade Forum
Vision 2000
Delphi
Domain Rates
Search
Music
Opinion Award
About
FeedBack
Quit


Delphi Tips & Tricks

| Tips & Tricks | Bug List | Cool Delphi Sites |
| Connectivity | Delphi 2.0 Features | Internet |

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 |

For Queries Mail To Webmaster

Copyright © 1996 Asylum Software Pvt. Ltd. This is an ASPL production.
Produced in conjunction with ASPL DELPHI TEAM.
Last revised November 27, 1996.