type
PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTRUCT;
TKBDLLHOOKSTRUCT = record
vkCode,
scanCode,
flags,
time: DWORD;
dwExtraInfo: Pointer;
end;
const
WH_KEYBOARD_LL = 13;
function LowLevelKeyboardProc(nCode:integer;WParam:WPARAM;LParam:LPARAM):LRESULT;stdcall;
var
fEatKeystroke:BOOL;
p:PKBDLLHOOKSTRUCT;
begin
result:=0;
fEatKeystroke := false;
p:=PKBDLLHOOKSTRUCT(lparam);
if (ncode=HC_ACTION) then
begin
case wparam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
featkeystroke :=(p.vkcode = VK_Lwin) or (p.vkcode = VK_Rwin)or (p.vkcode = VK_apps);
end;
end;
if featkeystroke = true then
result:=1;
if ncode <> 0 then
result := callnexthookex(0,ncode,wparam,lparam);
end;
procedure TForm1.FormCreate(Sender: TObject);
var hhklowlevelkybd: HHOOK;
begin
hhklowlevelkybd := SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, HInstance, 0);
end;