View on GitHub

Devendra's Log

USB device information using WMI

The System.Management namespace of the .NET framework has some Windows-specific features for recovering information regarding a USB device. The following list of Windows Management Instrumentation (WMI) classes are enough to recover almost all information one could need regarding the device.

The FriendlyName attribute is common to all of these classes and can be used to filter for a specific device.

This is how one can query for a specific USB device if you have a product and vendor ID for it

  ManagementObjectSearcher searcher = new ManagementObjectSearcher(
    "SELECT PNPDeviceID, Name, Service FROM Win32_PnPEntity WHERE PNPDeviceID LIKE "
    + "'%VID[_]xxxx&PID[_]xxxx%'");

  foreach (ManagementObject entity in searcher.Get())
    // do something useful

The Service field can be used to determine which system driver is being used, or filter results based on it.

These are some values the field can assume

Kudos to Emerson de Lira Espinola for helping out with this.