怎样用键盘hook屏蔽掉win键,win+d,win+f,win+e,有几种方法,谢谢

解决方案 »

  1.   

    不要这么麻烦用hook啊,把他们注册成热健就可以了,具体看我的帖子http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462
      

  2.   

    unit Udisable;interfaceuses
    Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
    Dialogs, StdCtrls;
    type
    tagKBDLLHOOKSTRUCT = packed record
    vkCode: DWORD;//????
    scanCode: DWORD;//????(????)
    {??????,???????,MSDN????????,??
    ??????,??????????(???)?1?ALT????0???}
    flags: DWORD;
    time: DWORD;//?????
    dwExtraInfo: DWORD;//??????????
    end;
    KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
    PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;//?????????????,Delphi???,??????
    const WH_KEYBOARD_LL = 13;
    //????????????????flags?????ALT?????
    const LLKHF_ALTDOWN = $20;
    //----??????-------------
     function LowLevelKeyboardProc(nCode: Integer;
    WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
     procedure hookstar; //????
     procedure hookend;
    var
    hhkLowLevelKybd: HHOOK;
    implementation
    {
    ??:???????????,???????
    ??:nCode ?Hook???
    WParam ???????
    LParam ?????????????????KBDLLHOOKSTRUCT???
    ???:????0??windows????????,??????????????
    }
    function LowLevelKeyboardProc(nCode: Integer;
    WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
    var
    fEatKeystroke: BOOL;
    p: PKBDLLHOOKSTRUCT;
    begin
      Result := 0;
      fEatKeystroke := FALSE;
      p := PKBDLLHOOKSTRUCT (lParam);
      //nCode??HC_ACTION???WParam?LParam?????????
      if (nCode = HC_ACTION) then
      begin
        //????????????Ctrl+Esc?Alt+Tab??Alt+Esc????
        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 //
            (p.vkCode = VK_Lwin) or (p.vkCode = VK_Rwin)or (p.vkCode = VK_apps) or  //?????WIN??
            //((p.vkCode = VK_CONTROL) and (P.vkCode = LLKHF_ALTDOWN) and (P.vkCode = VK_Delete)) 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))) //AND (p.flags = true) ;
        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
      begin
      hhkLowLevelKybd := SetWindowsHookExW(WH_KEYBOARD_LL,
                                           LowLevelKeyboardProc,
                                           Hinstance,
                                            0);
        if hhkLowLevelKybd <> 0 then
       //MessageBox(0, '????????!', '??', MB_OK)
      else
       // MessageBox(0, '????????!', '??', MB_OK);
      end
      else
      //MessageBox(Handle, '???????!', '??', MB_OK);
    end;
    //---------------------??????-----------------procedure hookend;//??????
    begin
    if hhkLowLevelKybd <> 0 then
    if UnhookWindowsHookEx(hhkLowLevelKybd) <> False then
    begin
    //MessageBox(0, '????????!', '??', MB_OK);
    hhkLowLevelKybd := 0;
    end
    else
    //MessageBox(Handle, '????????!', '??', MB_OK)
    else
    //MessageBox(Handle, '????????!', '??', MB_OK);
    end;
    //-------------????????-------------------------end.//-------------------????????--------------------
    function DynamicResolution(X, Y: word): BOOL;
    var
      lpDevMode: TDeviceMode;
    begin
      Result := EnumDisplaySettings(nil, 0, lpDevMode);
      if Result then
      begin
        lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
        lpDevMode.dmPelsWidth := X;
        lpDevMode.dmPelsHeight := Y;
        lpDevMode.dmDisplayFrequency := 75;
         Result := ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL;
      
      end;
      end;
    end.hookstar 屏蔽
    hookend  撤销
      

  3.   

    up 不过不能屏蔽
    ctrl+alt+del
      

  4.   

    谢谢linx88(haozi),不过我用delphi5编译执行后并不能屏蔽掉win键,一按win键,开始菜单还是
    会跳出来,不知我错在哪里,跟踪执行hookend时 hhkLowLevelKybd=0,是不是表示hook没有生成
      

  5.   

    win2000下测试通过,win98下呢,如何屏蔽win键
      

  6.   

    把他们注册成热健就可以了,具体看我的帖子http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462
      

  7.   

    谢谢ljmanage(过客),用注册成热健的方法会和其他程序有冲突,难道就没有win98下屏蔽win键的钩子
      

  8.   

    把它挖掉:)用Hook ,可以参考一下: linx88(haozi) 的贴子
      

  9.   

    linx88(haozi)的代码只能在2000下用
      

  10.   

    注册成热健,看我的帖子,你有没有看呢
    http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.5023462
    里面写着,在程序得到焦点时注册,失去焦点时释放,就不会和别的程序冲突我在其中屏蔽Tab健,没有问题,在别的程序中可以用