我有一个代码可以帮助我检测连接到PC的所有USB设备。但我想只检测连接到我的电脑的HID设备。 我写的代码是
WqlEventQuery insertQuery = new WqlEventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_USBControllerdevice'");
ManagementEventWatcher insertWatcher = new ManagementEventWatcher(insertQuery);
insertWatcher.EventArrived += new EventArrivedEventHandler(DeviceInsertedEvent);
insertWatcher.Start();
是否有任何查询我们只能获取HID(人机接口设备)连接的设备。