ManagementScope sc =
new ManagementScope(@"\\YOURCOMPUTERNAME\root\cimv2");
ObjectQuery query =
new ObjectQuery("Select * from Win32_USBHub");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(sc, query);
ManagementObjectCollection result = searcher.Get();
foreach (ManagementObject obj in result)
{
if (obj["Description"] != null) Console.WriteLine("Description:\t" + obj["Description"].ToString());
if (obj["DeviceID"] != null) Console.WriteLine("DeviceID:\t" + obj["DeviceID"].ToString());
if (obj["PNPDeviceID"] != null) Console.WriteLine("PNPDeviceID:\t" + obj["PNPDeviceID"].ToString());
}
WMI Code creator : http://sdrv.ms/PZKlKu
http://stackoverflow.com/a/6643234
https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3003f55-aecf-41da-b0a8-1b5e8bf99894/extracting-serial-number-vendor-id-and-product-id-from-usb-pendrive-using-c?forum=netfxbcl
Answer:WMI: Get USB device description on insertion https://t.co/3EjWHFmXiD
— ศรรามไงจะใครล่ะ❤️ (@sornram9254) June 3, 2016
Extracting S/N, vendor id and product id from USB pendrive using C#https://t.co/x14T5rEzNE
WMI Code creator: https://t.co/UG3oqpVu1W
— ศรรามไงจะใครล่ะ❤️ (@sornram9254) June 3, 2016
Published by