简体   繁体   中英

Disabling the keyboard in windows c++?

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 did consider using a keyboard driver but I think you need to restart the computer after it is installed, but since I only need to disable it for a couple minutes that wouldn't really work.

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.

您不能在不移除键盘或更换键盘驱动程序的情况下禁用Ctrl - Alt - Delete ,它会生成内核级通知。

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

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

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.

如果你想暂时禁用 Ctrl+Alt+Del,我建议通过使用 SuspendThread() 然后从 processthreadsapi.h 使用 ResumeThread() 暂停 winlogon(你必须烦人的管理员)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM