반응형
type PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTURCUT; TKBDLLHOOKSTURCUT = record vkCode, scanCode, flag, time, dwExtraInfo: DWORD; end; private hhookCurrent: HHOOK; ------------------------------------------------------------------------------------------------------------------- function KeyBoardProc( icode: integer; wParam: integer; lParam: integer): integer; stdcall; var p: PKBDLLHOOKSTRUCT; fEatKeystroke: Boolean; begin fEatKeystroke := False; if ( icode = HC_ACTION ) then begin case ( wParam ) of WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, WM_SYSKEYUP: begin p := PKBDLLHOOKSTRUCT( lParam ); // Alt + Tab, Ctrl + Esc, Alt + F4, Alt + Esc 막기 fEatKeystroke := ( p^.vkCode = VK_TAB ) and ( ( p^.flag and $00000020 ) <> 0 ) or ( p^.vkCode = VK_ESCAPE ) and ( ( p^.flag and $00000020 ) <> 0 ) or ( p^.vkCode = VK_F4 ) and ( ( p^.flag and $00000020 ) <> 0 ) or ( p^.vkCode = VK_ESCAPE ) and ( ( GetKeyState( VK_CONTROL ) and $8000 ) <> 0 ) or ( p^.vkCode = VK_LWIN) or ( p^.vkCode = VK_RWIN) or ( p^.vkCode = VK_CONTROL) or ( p^.vkCode = VK_MENU); end; end; end; if fEatKeystroke then result := 1 else result := CallNextHookEx(0, iCode, wParam, lParam); end; procedure Tfrm_Main.FormCreate(Sender: TObject); begin hhookCurrent := SetWindowsHookEx( 13{WH_KEYBOARD_LL}, @KeyBoardProc, HInstance, 0 ); end; procedure Tfrm_Main.FormDestroy(Sender: TObject); begin ExitWindows(EWX_force, 0); end;
반응형
'Programming > Delphi' 카테고리의 다른 글
맥 어드레스 알아내기 (0) | 2010.07.25 |
---|---|
레지스트리에 신뢰하는 웹사이트 등록하기 (0) | 2010.07.25 |
델파이 Key Constants (0) | 2010.07.21 |
런타임 중에 컨트롤 사이즈 조절하기 (439) | 2010.07.20 |
특정 폴더 오픈하기 (0) | 2010.07.02 |