We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Is it possible to detect an usb device when the device is plugged in??

Last post 06-24-2008 2:37 PM by sluice. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-05-2008 2:28 PM

    • yonghanon
    • Not Ranked
    • Joined on 05-05-2008
    • Indonesia
    • New Member
    • Points 10

    Is it possible to detect an usb device when the device is plugged in??

    I want to ask,is it possible to detect a device that are connected to the usb port?And directly link to the software that we've made?Thanks a lot
    • Post Points: 10
  • 06-24-2008 2:37 PM In reply to

    • sluice
    • Not Ranked
    • Joined on 06-24-2008
    • United Kingdom
    • New Member
    • Points 10

    Re: Is it possible to detect an usb device when the device is plugged in??

    You would need to use WMI to detect your USB devices. It depends on whether you are directly attached to a USB port on your PC or through a hub. Using WMI Code Creator (a freebie), I generated this: 

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_USBHub",,48)
    For Each objItem in colItems
        Wscript.Echo "-----------------------------------"
        Wscript.Echo "Win32_USBHub instance"
        Wscript.Echo "-----------------------------------"
        Wscript.Echo "Name: " & objItem.Name
    Next

     ____________________________________

    I hope that gets you along the way.

    • Post Points: 5
Page 1 of 1 (2 items)