also strg+esc kannste mit diesem keyboard hook sperren.
Delphi-Quellcode:
library KeyboardHook;
uses
Windows,
SysUtils,
Classes;
{$R *.res}
type
TKeybDLLHookStruct = packed record
vkCode: integer;
scanCode: integer;
flags: integer;
time: integer;
dwExtraInfo: integer;
end;
PKeybDLLHookStruct = ^TKeybDLLHookStruct;
const
WH_KEYBOARD_LL = 13;
var
hKeyHook: THandle;
function KeyboardProc_LowLevel(code: integer; wParam, lParam: Integer): integer; stdcall;
var
P: PKeybDLLHookStruct;
KeyDown: Boolean;
begin
if Code < 0 then
result := CallNextHookEx(hKeyHook, Code, wParam, lParam)
else
begin
P := Pointer(lParam);
KeyDown := P^.flags = 0;
if KeyDown and (P^.vkCode = VK_ESCAPE) and
Bool($8000 and GetAsyncKeyState(VK_CONTROL)) then
result := HC_SKIP
else result := CallNextHookEx(hKeyHook, Code, wParam, lParam);
end;
end;
procedure StartHook;
begin
hKeyHook := SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardProc_LowLevel, HInstance, 0);
end;
procedure StopHook;
begin
UnhookWindowsHookEx(hKeyHook);
end;
exports
StartHook,
StopHook;
begin
end.
bindeste so in dein prog ein:
Delphi-Quellcode:
interface
...
const
HookDLL = 'KeyboardHook.dll';
procedure StartHook; external HookDLL;
procedure StopHook; external HookDLL;
rufst dann einfach beim OnCreate von deinem form
StartHook;
und beim OnDestroy
StopHook;
auf