Delphi 윈도우즈 키 비활성화

1307 단어 windows
type
  tagKBDLLHOOKSTRUCT = packed record
    vkCode: DWORD;
    scanCode: DWORD;
    flags: DWORD;
    time: DWORD;
    dwExtraInfo: Pointer;
  end;
  KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
  PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;

const
  WH_KEYBOARD_LL = 13;
  WH_MOUSE_LL = 14;

var
  keyHookHandle: THandle;

function KeyHookProc(Code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT;
  stdcall;
var
  p: PKBDLLHOOKSTRUCT;
  bBlock: Boolean;
begin
  bBlock := False;
  if Code = HC_ACTION then begin
    case wParam of
      WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP: begin
        p := PKBDLLHOOKSTRUCT(lParam);
        if(p^.vkCode = VK_LWIN) or (p^.vkCode = VK_RWIN) then bBlock := True;
        if(p^.vkCode = VK_CONTROL) or (p^.vkCode = VK_ESCAPE) then bBlock := True;
        if(p^.vkCode = VK_MENU) or (p^.vkCode = VK_TAB) then bBlock := True;
      end;
      else begin
         bBlock := False;
      end;
    end;
  end;
  if bBlock = False then
    Result := CallNextHookEx(keyHookHandle, Code, wParam, lParam)
  else
    Result := 1
end;

좋은 웹페이지 즐겨찾기