VERSION 5.00 Begin VB.Form DetectForm Caption = "USB Device Selection" ClientHeight = 2430 ClientLeft = 7665 ClientTop = 6900 ClientWidth = 5775 LinkTopic = "MainForm" ScaleHeight = 162 ScaleMode = 3 'Pixel ScaleWidth = 385 StartUpPosition = 2 'CenterScreen Begin VB.ListBox DeviceList Height = 1425 ItemData = "DetectForm.frx":0000 Left = 0 List = "DetectForm.frx":0002 TabIndex = 2 Top = 0 Width = 4440 End Begin VB.CommandButton DetectButton Caption = "Redetect" Height = 375 Left = 4560 TabIndex = 1 Top = 600 Width = 1095 End Begin VB.CommandButton GoButton Caption = "Go" Height = 375 Left = 4560 TabIndex = 0 Top = 120 Width = 1095 End Begin VB.Label StatusMemo BackColor = &H80000005& BorderStyle = 1 'Fixed Single Height = 975 Left = 0 TabIndex = 3 Top = 1440 Width = 5775 WordWrap = -1 'True End End Attribute VB_Name = "DetectForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Public DetectOK As Boolean Public DeviceIndex As Long Dim DeviceOK(0 To 7) As Boolean Private Sub DetectButton_Click() Dim DeviceMask As Long Dim PID As Long Dim NameSize As Long Dim Name As String Dim I As Integer Dim Found As Boolean DeviceList.Clear Found = False DeviceMask = GetDevices() For I = 0 To 7 DeviceOK(I) = False If (DeviceMask And (2 ^ I)) <> 0 Then NameSize = 256 Name = Space$(NameSize) Call QueryDeviceInfo(I, PID, NameSize, ByVal Name, 0, 0) Name = Left(Name, NameSize) If ((PID >= &H8070&) And (PID <= &H807F&)) Then 'USB-AO16 family Found = True DeviceOK(I) = True Else Name = Name + " " End If 'PID Else Name = "" End If 'DeviceMask Call DeviceList.AddItem(Str$(I) + ": " + Name) Next I If Found Then StatusMemo.Caption = "Select the device you want to work with and click Go." Else StatusMemo.Caption = "No compatible devices found; your device may not be installed, or may not be installed properly. Click Redetect to check again." End If End Sub Private Sub Form_Load() Call DetectButton_Click DeviceList.Selected(0) = True End Sub Private Sub GoButton_Click() Dim I As Integer I = DeviceList.ListIndex If (I = -1) Or (Not DeviceOK(I)) Then 'No device index selected or Invalid device index selected Beep 'End Sub End If DetectOK = True DeviceIndex = I Me.Hide End Sub