0

I have used the following code in my C++ program( in VS2010) written for device monitoring.

hres = pSvc->ExecNotificationQueryAsync(
            _bstr_t("WQL"),
            _bstr_t("select * from __InstanceOperationEvent within 1 "
            "where (TargetInstance ISA 'Win32_Keyboard') "),
            WBEM_FLAG_SEND_STATUS,
            NULL,
            pStubSink);

This query works fine and returns the expected value if the keyboard connected is an USB keyboard. The query is not even fired if it is a PS/2 keyboard. I tried using Win32_PortConnector and Win32_Parallelport instead of Win32_Keyboard in the query. But the result was the same.

Can someone tell me how to get the notification when a PS/2 keyboard is connected to my system.

bytecode77
  • 14,163
  • 30
  • 110
  • 141
Jackzz
  • 1,417
  • 4
  • 24
  • 53
  • Last I checked, PS/2 doesn't allow for detection on being plugged in once the computer is already on. – chris Mar 16 '15 at 11:49
  • @chris : Are you sure about it? The documentation for `Win32_PortConnector` tells that `Win32_PortConnector WMI class represents physical connection ports, such as DB-25 pin male, Centronics, or PS/2.` – Jackzz Mar 16 '15 at 12:03
  • Can't say. I haven't used PS/2 for quite a while and I've never had to code for it, but I distinctly remember needing to restart the computer before the keyboard would work. – chris Mar 16 '15 at 12:22
  • @chris: Yes.. i needed to do it when the keyboard was plugged in for the first time. But after that I could easily unplug and plug the device again when the system was on, without the need to restart.Still couldn't detect it using the `WMI` query. – Jackzz Mar 16 '15 at 12:52
  • As far as I know that's possible - PS/2 isn't plug and play nor it is swappable therefore there's no notification for plugging it. Just because it continues working if you unplug and plug it back doesn't mean that Windows was ever aware that you unplugged it in the first place - it only continues working because your hardware (mainboard) handles it. Google for PS/2 hot plugging, hot swapping and pnp. – bokibeg Mar 17 '15 at 12:54

0 Answers0