在USB\VID_05A9&PID_2800\5&1BFE1C47&0&8里面,USB代表设备类型, 5&1BFE1C47&0&8代表设备连接位置,包括总线位置,控制器位置,控制器编号,端口编号这几项, 而VID_05A9&PID_2800则是设备信息,USB的驱动也正是依赖于这个, VID其实是Vendor ID(生产厂商ID),PID则是Product ID(产品ID),分别代表生产商的编号和生产商内部的产品编号。 原则上说一个USB设备必须有PID和VID,属于USB接口芯片的可选设置。
///////////////////////////即插即用总线信息///////////////////////////// ManagementObjectSearcher mos0 = new ManagementObjectSearcher(@"select * from Win32_Bus where DeviceID like 'PNP_BUS%'"); foreach (ManagementObject mo in mos0.Get()) { foreach (PropertyData p in mo.Properties) { Console.WriteLine(p.Name + "--------" + p.Value); } }
/////////////////////////////////USB控制器以及连接的设备///////////////////////////////// ManagementObjectSearcher moc1 = new ManagementObjectSearcher(@"select * from Win32_USBController where Manufacturer='Intel'"); foreach (ManagementObject mo1 in moc1.Get()) { foreach (PropertyData p in mo1.Properties) { Console.WriteLine(p.Name + "--------" + p.Value); } }
//////////////////////USB控制器以及当前与他们相关联的设备的集合////////////////////// ManagementObjectSearcher mos1 = new ManagementObjectSearcher(@"select * from Win32_USBControllerDevice"); foreach (ManagementObject mo1 in mos1.Get()) { foreach (PropertyData p in mo1.Properties) { Console.WriteLine(p.Name + "--------" + p.Value); } }
////////////////////////////////即插即用的某一个USB设备////////////////////////////////// ManagementObjectSearcher mos = new ManagementObjectSearcher(@"select * from Win32_PnPEntity where DeviceID like '%usb%mi%' and (Manufacturer like 'microsoft' or Service='usbvideo')"); foreach (ManagementObject mo in mos.Get()) { foreach (PropertyData p in mo.Properties) { if ((p.Name == "Caption") || (p.Name == "ClassGuid") || (p.Name == "DeviceID") || (p.Name == "PNPDeviceID")) { Console.WriteLine(p.Name + "--------" + p.Value); } } }
|
请发表评论