• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

delphihookalt+F4ctrl+delete+altwin键等

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

unit uHook;


interface


uses
  Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, Dialogs,
  StdCtrls;


type
  tagKBDLLHOOKSTRUCT = packed record
    vkCode: DWORD;
    scanCode: DWORD;
    flags: DWORD;
    time: DWORD;
    dwExtraInfo: DWORD;
  end;


  KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;


  PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;


const
  WH_KEYBOARD_LL = 13;


const
  LLKHF_ALTDOWN = $20;


function LowLevelKeyboardProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;


procedure hookstar;


procedure hookend;


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
//    ((p.vkCode=VK_ESCAPE) and ((p.flags and LLKHF_ALTDOWN) <> 0))or
//    (p.vkCode=VK_Lwin) or
//    (p.vkCode=VK_Rwin) or
//    (p.vkCode=VK_apps) or
//    ((p.vkCode=VK_ESCAPE) and ((GetKeyState(VK_CONTROL) and $8000) <> 0)) or
    ((p.vkCode=VK_F4) and ((p.flags and LLKHF_ALTDOWN) <> 0))
//    or
//    ((p.vkCode=VK_SPACE) and ((p.flags and LLKHF_ALTDOWN) <> 0)) or
//    (((p.vkCode=VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN and p.flags) and (P.vkCode=VK_Delete)))
    end;
  end;
  if fEatKeystroke = True then
    Result := 1;
  if nCode <> 0 then
    Result := CallNextHookEx(0, nCode, wParam, lParam);
end;


procedure HookStar;
begin
  if hhkLowLevelKybd = 0 then
    hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL, LowLevelKeyboardProc, Hinstance, 0);
end;


procedure HookEnd;
begin
  if (hhkLowLevelKybd <> 0) and UnhookWindowsHookEx(hhkLowLevelKybd) then
    hhkLowLevelKybd := 0;
end;


initialization
  hookstar;


finalization
  hookend;


end.

 

http://blog.csdn.net/y281252548/article/details/52623199


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
曾经用Delphi写的一个上位机发布时间:2022-07-18
下一篇:
DELPHIXE5-8弹出列表框供选择发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap