完全阻止键盘输入

时间:2012-01-31 17:30:11

标签: windows delphi winapi kiosk-mode

有没有办法完全阻止键盘输入?这也应该阻止像WIN + E这样的关键组合。

我发现这个代码,无论如何都要将它改为仅阻止键盘输入(鼠标需要工作)

    procedure TForm1.Button1Click(Sender: TObject) ;

   function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
   var
     lib: THandle;
   begin
     result := false;
     p := nil;
     if LoadLibrary(PChar(dllName)) = 0 then exit;
     lib := GetModuleHandle(PChar(dllName)) ;
     if lib <> 0 then
     begin
      p := GetProcAddress(lib, PChar(funcName)) ;
      if p <> nil then Result := true;
     end;
   end;

   var
     BlockInput : function(Block: BOOL): BOOL; stdcall;

   begin
    if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
    begin
     ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
     BlockInput(true) ;
     Sleep(5000) ;
     BlockInput(false) ;
    end;
   end;

 end.

此代码是否也适用于WIN键等?

谢谢!

2 个答案:

答案 0 :(得分:8)

你的想法太难了。

设置可由鼠标而不是键盘控制的信息亭的适当方法是没有连接键盘。(这也使得不道德的信息亭用户无法使用偷你的键盘。)

这也意味着,如果您需要执行管理任务,您可以附加一个键盘(或遥控器),一切都会正常工作。

答案 1 :(得分:2)

如果由于某种原因删除键盘不是一个可行的选项,则在软件中执行此操作的方式不受支持:从

中删除UpperFilters值
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96B-E325-11CE-BFC1-08002BE10318}

这会禁用所有普通键盘设备的输入,但远程桌面虚拟键盘仍然有效,因此您可能需要确保远程桌面已配置并先运行。

为了您的参考,如果您想要反转该过程,UpperFilters通常是包含单个字符串“kbdclass”(没有引号)的REG_MULTI_SZ。

相关问题