Results 1 to 4 of 4

Thread: [RESOLVED] Enumerate USB Devices

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    34

    Resolved [RESOLVED] Enumerate USB Devices

    I have spent most of the day looking for this information and cannot seem to find what I am after.

    I simply want to get a list of the USB devices attached to a particular computer so that I can say that a particular device is attached. The motivation for this stems from an application I am developing that utilizes a USB biometric authentication device. I have the entire app developed, and functioning through an API provided by the manufacturer. However, if I try to make a call to that API and the USB device is not connected, the entire application shuts down (the problem is the same in the manufacturers sample app, so I know it is not just me).

    So, I am really just after a way to either determine that the device is not connected before I make a call to the API which communicates with the USB device, or a way to prevent the API from killing my application when it has an error communicating with the device.

    Thank you for your input and assistance!!

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,817

    Re: Enumerate USB Devices

    Quote Originally Posted by mitgiraffe
    I have spent most of the day looking for this information and cannot seem to find what I am after.

    I simply want to get a list of the USB devices attached to a particular computer so that I can say that a particular device is attached. The motivation for this stems from an application I am developing that utilizes a USB biometric authentication device. I have the entire app developed, and functioning through an API provided by the manufacturer. However, if I try to make a call to that API and the USB device is not connected, the entire application shuts down (the problem is the same in the manufacturers sample app, so I know it is not just me).

    So, I am really just after a way to either determine that the device is not connected before I make a call to the API which communicates with the USB device, or a way to prevent the API from killing my application when it has an error communicating with the device.

    Thank you for your input and assistance!!
    Hi,

    Here's a link about USB Devices, perhaps there's something for you;

    http://search.msdn.microsoft.com/sea...ery=USB+device

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    34

    Re: Enumerate USB Devices

    Unfortunantly I've already looked through many of these links and cannot seem to find what I need.

    I have also looked into using WMI, but cannot seem to find anywhere that contains information about the USB Devices connected to the system.

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    34

    Re: Enumerate USB Devices

    I believe I have finally found a resolution to my problem. The information I was looking for was in Win32_PnPEntity in the WMI. This table contains very similiar information to that in the Device Manager. The following code can be used to see if a device is connected to the computer.

    Public Function DeviceDetected(ByVal DeviceName As String) As Boolean
    ' See if the desired device shows up in the device manager.
    Dim info As System.Management.ManagementObject
    Dim search As System.Management.ManagementObjectSearcher
    Dim Name As String

    search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
    For Each info In search.Get()
    ' Go through each device detected.
    Name = CType(info("Caption"), String) ' Get the name of the device.
    If InStr(Name, DeviceName, CompareMethod.Text) > 0 Then
    ' The device is what we're looking for.
    Return True
    End If
    Next
    'We did not find the device we were looking for
    Return False
    End Function

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