在 C# 中检测 PS/2 端口状态
我试图简单地检测我的机器上的 PS/2 端口是否连接有键盘。这个想法是计算机将启动,但如果它检测到 USB 设备或 PS/2 键盘,它会重新启动到管理员模式。
我已经处理了 USB 方面的问题,尽管我没有找到有关 PS/2 端口的任何文档。有些帖子说启动后不可能检测到插入 PS/2 端口的键盘,尽管我只是想检查启动时是否有连接。
我在我的程序中使用 C#,因此这种语言的任何解决方案都将非常有帮助,尽管任何语言的帮助都是有益的。
I am attempting to simply detect whether there is a keyboard attached to the PS/2 port on my machine. The idea is that the computer will boot up, although if it detects a USB device or PS/2 keyboard, it reboots into an administrator mode.
I have handled the USB aspect, although I have had no luck in finding any documentation for the PS/2 port. Some posts have said it is not possible to detect a keyboard plugged into a PS/2 port after boot, although I simply wish to check whether there is one connected at boot time.
I am using C# for my program and therefore any solution in this language would be very helpful, although assistance in any language would be beneficial.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WMI 似乎正在这样做:
返回:
我没有 PS/2 键盘,因此状态会出现错误,但如果已连接,则状态应该为“正常”。
WMI seems to be doing it:
returns:
I don't have a PS/2 keyboard, so the status gives an error, but you should have an OK status if one is connected.
WMI 应该允许您找到它。有一个很棒的实用程序,WMI Code Creator,允许查找并打开不同的 WMI 类并生成各种格式的代码,VBScript, C# 等,在搜索类时,使生活变得更加轻松。
作为一般的顶级参考,我还发现这很有帮助:WMI 任务:计算机硬件
WMI should allow you to find it. There is a fantastic utility, WMI Code Creator, that allows to find and open different WMI classes and generate code in various formats, VBScript, C#, etc. which, when searching through the classes, makes life a lot easier.
As a general top level reference, I also found this helpful: WMI Tasks: Computer Hardware