List Human Interface Devices using C #

1

I'm having trouble figuring out how to list and access a device on the PC, remembering that although the input is USB it's recognized as an HID human interface device type mouse or keyboard. >

I've already seen several and several of the most promising sites I've found would be using a select with ManagementObjectSearcher dai would access the class win32 but I did not find any options in it that would return the HIDs or at least I did not find the correct form.

    
asked by anonymous 30.05.2014 / 22:13

1 answer

1

For example:

If you are going to print the name of all% of your computer's% sites, it would be:

System.Management.ManagementClass usbClass = new ManagementClass("Win32_USBHub");
System.Management.ManagementObjectCollection usbCollection = usbClass.GetInstances();
foreach (ManagementObject usb in usbCollection)
{

    System.Console.WriteLine("{0} {1} {2}", 
        "HID".Contains((string)usb.GetPropertyValue("PNPDeviceID")), 
        usb.GetPropertyValue("name"),
        usb.GetPropertyValue("PNPDeviceID"));
}
    
30.05.2014 / 23:12