Disabling the keyboard in windows c++?

后端 未结 6 2089
轻奢々
轻奢々 2021-01-06 13:56

How can I completely disable the keyboard using c++ in windows? And by completely disable I mean so even Ctrl+Alt+Delete doesn\'t work. I di

相关标签:
6条回答
  • 2021-01-06 14:19

    You can't disable Ctrl-Alt-Delete without removing the keyboard or replacing the keyboard driver, it generates a kernel level notification.

    0 讨论(0)
  • 2021-01-06 14:20

    This is not really possible.

    WinLogon is designed as the one process that intercepts the Ctrl+Alt+Del key press, even when all other things hang or die. This is the failsafe against malicious sessions, etc. So there is no obvious workaround.

    Maybe a keyboard filter driver would make your request possible, but that is a real kernel-driver.

    0 讨论(0)
  • 2021-01-06 14:24

    Ok, here goes several random suggestions. I don't have a definitite answer, but here's where I would start:

    1) SetupDiRemoveDevice is probably the API you want to call. Although to call it, you'll need to make a lot of other device enumeration calls. Enumerate your HID and USB devices and find the keyboard. Start by looking for the VID/PID of the actual device for starters.

    2) Delete the drivers kdbclass.sys and kbdhid.sys. You'll be fighting Windows system file to do this. I have no idea if this will work, but sounds interesting and simple.

    3) Write a USB filter driver. Your driver will need to know (or be passed) the vid/pid of the device to filter on, but it might work.

    0 讨论(0)
  • 2021-01-06 14:30

    You could use BlockInput function. But it doesn't block CTRL + ALT + DEL.

    0 讨论(0)
  • 2021-01-06 14:36

    You could install a keyboard hook and filter out the messages, but you might need to have your application as the top most window. Even then Ctrl+Alt+Del would not get filtered out.

    Here's SetWindowsHookEx on MSDN

    Example of Hooking the Keyboard

    0 讨论(0)
  • 2021-01-06 14:38

    If you want to disable Ctrl+Alt+Del temporarily, I would recommend suspending winlogon (ofc you have to be admin annoyingly) by using SuspendThread() then ResumeThread() from processthreadsapi.h

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