Results 1 to 4 of 4

Thread: How are devices identified uniquely?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    19

    How are devices identified uniquely?

    Friends

    I am working on a project which requires detection of USB devices.
    For this i am using WMI and using the class Win32_USBHub.
    This class returns many properties like Device_ID, DESCRIPTION, Name etc.

    but i would like to know how windows actually identifies a device.

    For eg :- pen drive, keyboards, mouse, digital cameras etc.

    Description for Pen Drive and Digital Camera gives "Mass storage device" .
    So i cannot use Description property

    Problem with Device_ID is every pen drive has got different Device_ID.
    I want something that will uniquley address a pen drive device irrespective of their device_id.

    Please help...
    (Note:- solution in WMI is preferable)

    THANK YOU

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How are devices identified uniquely?

    Here is the WMI code to detect the USB controllers/devices on your system. It was generated by Scriptomatic v2 from MS that you can download for free.

    Note the results from my system is trimmed down to remove the controllers and I only left the device - my Sony digital camera. It specifies "REMOVABLEMEDIA" as a type. I didnt get my pen drive out for the test but I would think it would show as different. Maybe I'll try it now.

    VB Code:
    1. On Error Resume Next
    2.  
    3. Const wbemFlagReturnImmediately = &h10
    4. Const wbemFlagForwardOnly = &h20
    5.  
    6. arrComputers = Array("VBGURU")
    7. For Each strComputer In arrComputers
    8.    WScript.Echo
    9.    WScript.Echo "=========================================="
    10.    WScript.Echo "Computer: " & strComputer
    11.    WScript.Echo "=========================================="
    12.  
    13.    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    14.    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice", "WQL", _
    15.                                           wbemFlagReturnImmediately + wbemFlagForwardOnly)
    16.  
    17.    For Each objItem In colItems
    18.       WScript.Echo "AccessState: " & objItem.AccessState
    19.       WScript.Echo "Antecedent: " & objItem.Antecedent
    20.       WScript.Echo "Dependent: " & objItem.Dependent
    21.       WScript.Echo "NegotiatedDataWidth: " & objItem.NegotiatedDataWidth
    22.       WScript.Echo "NegotiatedSpeed: " & objItem.NegotiatedSpeed
    23.       WScript.Echo "NumberOfHardResets: " & objItem.NumberOfHardResets
    24.       WScript.Echo "NumberOfSoftResets: " & objItem.NumberOfSoftResets
    25.       WScript.Echo
    26.    Next
    27. Next

    VB Code:
    1. AccessState:
    2. Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24D2&SUBSYS_80A61043&REV_02\\3&267A616A&0&E8"
    3. Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\\DISK&VEN_SONY&PROD_SONY_DSC&REV_4.50\\6&35C56897&0"
    4. NegotiatedDataWidth:
    5. NegotiatedSpeed:
    6. NumberOfHardResets:
    7. NumberOfSoftResets:
    8.  
    9. AccessState:
    10. Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24D2&SUBSYS_80A61043&REV_02\\3&267A616A&0&E8"
    11. Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\\REMOVABLEMEDIA\\7&5D1629E&0&RM"
    12. NegotiatedDataWidth:
    13. NegotiatedSpeed:
    14. NumberOfHardResets:
    15. NumberOfSoftResets:
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How are devices identified uniquely?

    Ok here it is for my jump drive or pen drive. There is an identifier between the 2.
    VB Code:
    1. AccessState:
    2. Antecedent: \\VBGURU28\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24DD&SUBSYS_80A61043&REV_02\\3&267A616A&0&EF"
    3. Dependent: \\VBGURU28\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\\DISK&VEN_&PROD_USB_DISK_PRO&REV_1.13\\483619010A5B&0"
    4. NegotiatedDataWidth:
    5. NegotiatedSpeed:
    6. NumberOfHardResets:
    7. NumberOfSoftResets:
    8.  
    9. AccessState:
    10. Antecedent: \\VBGURU\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_24DD&SUBSYS_80A61043&REV_02\\3&267A616A&0&EF"
    11. Dependent: \\VBGURU\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\\REMOVABLEMEDIA\\7&D5604D5&0&RM"
    12. NegotiatedDataWidth:
    13. NegotiatedSpeed:
    14. NumberOfHardResets:
    15. NumberOfSoftResets:
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    19

    Re: How are devices identified uniquely?

    I am sorry, but i donot understand what is happening???
    I would be gr8ful if u could explain me what is going on???
    Why do u need an array in the first place?
    By the way which property is giving u removable media???

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width