VERSION 5.00 Begin VB.Form DetectForm Caption = "Device Selection - USB-IIRO4-2SM Sample" ClientHeight = 2430 ClientLeft = 7665 ClientTop = 6900 ClientWidth = 3855 LinkTopic = "MainForm" ScaleHeight = 162 ScaleMode = 3 'Pixel ScaleWidth = 257 StartUpPosition = 2 'CenterScreen Begin VB.ListBox DeviceList Height = 1425 Left = 0 TabIndex = 2 Top = 0 Width = 2520 End Begin VB.CommandButton DetectButton Caption = "Redetect" Height = 375 Left = 2640 TabIndex = 1 Top = 600 Width = 1095 End Begin VB.CommandButton GoButton Caption = "Go" Height = 375 Left = 2640 TabIndex = 0 Top = 120 Width = 1095 End Begin VB.Label StatusMemo BackColor = &H00FFFFFF& BorderStyle = 1 'Fixed Single Height = 975 Left = 0 TabIndex = 3 Top = 1440 Width = 3855 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 Private Declare Function GetDevices Lib "AIOUSB" Alias "VBGetDevices" () As Long Private Declare Function QueryDeviceInfo Lib "AIOUSB" Alias "VBQueryDeviceInfo" (ByVal DeviceIndex As Long, ByRef PID As Long, ByRef NameSize As Long, ByVal Name As String, ByRef DIOBytes As Long, ByRef Counters As Long) As Long Dim DeviceOK(0 To 7) As Boolean Dim DetectOK As Boolean Dim DeviceIndex As Long Function getIndex() As Long If DetectOK = True Then getIndex = DeviceIndex Else getIndex = -1 End If End Function 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 = &H8030&) Or (PID = &H8031&) Then 'USB-IIRO4-2SM 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 Form_Unload(Cancel As Integer) Beep 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 DetectOK = False Else DetectOK = True DeviceIndex = I Me.Hide End If End Sub