Can task-switching keyboard shortcuts be disabled in W7 using Delphi?

前端 未结 4 1811
栀梦
栀梦 2021-01-04 22:43

MY application has had a mode for years where the customer can \'disable access to the OS\'. Obviously this feature goes against the grain (at least as far as Windows is con

相关标签:
4条回答
  • 2021-01-04 23:04

    As David has pointed out, this is called "Kiosk Mode". A couple of good articles (part 1 and part 2) can be found on About.com.

    0 讨论(0)
  • 2021-01-04 23:10

    There is Windows Embedded Standard 7 that you can package in a way that has a true kiosk mode.

    0 讨论(0)
  • 2021-01-04 23:13

    If found a solution:

    function LowLevelKeyboardProc(nCode: integer; wParam: WPARAM; lParam: LPARAM):
      LRESULT; stdcall;
    type
      PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTRUCT;
      TKBDLLHOOKSTRUCT = record
        vkCode: cardinal;
        scanCode: cardinal;
        flags: cardinal;
        time: cardinal;
        dwExtraInfo: Cardinal;
      end;
    
      PKeyboardLowLevelHookStruct = ^TKeyboardLowLevelHookStruct;
      TKeyboardLowLevelHookStruct = TKBDLLHOOKSTRUCT;
    const
      LLKHF_ALTDOWN = $20;
    var
      hs: PKeyboardLowLevelHookStruct;
      ctrlDown: boolean;
    begin
    
      if nCode = HC_ACTION then
      begin
    
        hs := PKeyboardLowLevelHookStruct(lParam);
        ctrlDown := GetAsyncKeyState(VK_CONTROL) and $8000 <> 0;
        if (hs^.vkCode = VK_ESCAPE) and ctrlDown then
          Exit(1);
        if (hs^.vkCode = VK_TAB) and ((hs^.flags and LLKHF_ALTDOWN) <> 0) then
          Exit(1);
        if (hs^.vkCode = VK_ESCAPE) and ((hs^.flags and LLKHF_ALTDOWN) <> 0) then
          Exit(1);
        if (hs^.vkCode = VK_LWIN) or (hs^.vkCode = VK_RWIN) then
          Exit(1);
    
      end;
    
      result := CallNextHookEx(0, nCode, wParam, lParam);
    
    end;
    
    procedure TForm1.FormShow(Sender: TObject);
    begin
      SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, 0, 0);
    end;
    

    This disables (as you can see!)

    • Ctrl+Esc (show start menu)
    • Alt+Tab (task switch)
    • Alt+Esc (task switch)
    • Win (show start menu)
    • Win+Tab (3D task switch)
    • Win+D, Win+M, Win+Space, Win+Arrows, Win+P, Win+U, Win+E, Win+F, Win+Digit, ...
    • Almost any combination including the Windows key (but not all, e.g. Win+L)
    0 讨论(0)
  • 2021-01-04 23:17

    dWinLock also provides a solution. IIRC, they install a service that can stop Ctrl+Alt+Del.

    0 讨论(0)
提交回复
热议问题