Arsip: Contoh Unit Untuk Block Keyboard Keys,.,.,.,.


by J4ckR1pp3r in Sistem more 13 years ago 1569
Insomnia again,.,.,and again,.,.,.,. daripada bengong ga ada kerjaan,.,.
mending corat coret ah,.,.,.,wkwkwkwk
Unit ini berfungsi untuk mem-block/disable beberapa kombinasi keyboard keys pada WinNT,.,.,.,. biar lebih mantap,.,.,. unit ini dibikin dll,..,.,. happy coding,.,.,.,.,

unit UBlockKeys;
interface
uses
Windows, Messages, SysUtils,  Classes;
type
tagKBDLLHOOKSTRUCT = packed record
vkCode: DWORD;
scanCode: DWORD;
flags: DWORD;
time: DWORD;
dwExtraInfo: DWORD;
end;
KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
const
WH_KEYBOARD_LL = 13;
LLKHF_ALTDOWN = $20;
function LowLevelKeyboardProc(nCode: Integer;WParam: WPARAM;
LParam: LPARAM):LRESULT; stdcall;
procedure BlockKeys;
procedure UnBlockKeys;
var
hhkLowLevelKybd: HHOOK;
implementation
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_TAB) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or // ALT+TAB
    ((p.vkCode = VK_ESCAPE) and ((p.flags and LLKHF_ALTDOWN) <> 0))or //ALT+ESC
    ((p.vkCode = VK_ESCAPE) and ((GetKeyState(VK_CONTROL) and $8000) <> 0))  or //CTRL+ESC
    ((p.vkCode = VK_F4) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or //ALT+F4
    ((p.vkCode = VK_SPACE) and ((p.flags and LLKHF_ALTDOWN) <> 0)); //ALT+SPACE
  end;
end;
if fEatKeystroke = True then
Result := 1;
if nCode <> 0 then
Result := CallNextHookEx(0, nCode, wParam, lParam);
end;
procedure BlockKeys;
begin
if hhkLowLevelKybd = 0 then
begin
hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL,
LowLevelKeyboardProc,
Hinstance,
0);
if hhkLowLevelKybd <> 0 then
else
end
else
end;
procedure UnBlockKeys;
begin
if hhkLowLevelKybd <> 0 then
if UnhookWindowsHookEx(hhkLowLevelKybd) <> False then
hhkLowLevelKybd := 0;
end;
end.
Syntax Highlighted with https://pascal-id.org/syntax
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com