View Single Post
Old 09-11-2006, 06:39 AM
George7a's Avatar
George7a George7a is offline
History: Jesus Is Risen
Join Date: Mar 2005
Location: Nazareth
Posts: 1,697


Use Windows Management Instrumentation (WMI) to enumerate the Physical Disks and report the PnP Device IDs. The Vendor and Product ID are part of the PnP Device ID. The PnP Device ID does not have the PCI Vendor and Product ID code (although they look a look alike). One of the cool features of WMI is it's ability to "associate" multiple entries (sorta like an inner join in SQL syntax). Here is a very crude example of how to "walk" the WMI associations to get the Vendor/Product IDs you want.
dim obj, objs, buf, PnPID ' Get the PnPDevice ID Set objs = GetObject("winmgmts:").InstancesOf("Win32_DiskDrive") for each obj in objs if obj.InterfaceType = "USB" then 'buf = "Model: " & obj.Model & vbcr 'buf = buf & "PnP Device ID: " & obj.PnPDeviceID PnPID = obj.PnPDeviceID 'msgbox(buf) end if next ' fix up the PnPDevice ID to make it suitable for comparing against the Association PnPID = replace(PnPID, "\", "\\") & chr(34) ' Use WMI associations to pair up USBContoller and PnPEntity Set objs = GetObject("winmgmts:").InstancesOf("Win32_USBControllerDevice") for each obj in objs if right(obj.Dependent, len(PnPID)) = PnPID then msgbox(PnPID & vbcr & obj.Dependent & vbcr & obj.Antecedent) end if next
I hope it helps,

- George
Reply With Quote