VERSION 5.00 Begin VB.Form DetectForm Caption = "Device Selection - USB-DIO-32 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 ItemData = "DetectForm.frx":0000 Left = 0 List = "DetectForm.frx":0002 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 = &H80000005& 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 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 >= &H8045&) And (PID <= &H8049&)) Or ((PID >= &H8145&) And (PID <= &H8149&)) Then 'USB-AI(O)16-64M 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() DetectButton_Click DeviceIndex = -1 DeviceList.ListIndex = 0 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 DeviceIndex = I Me.Hide End Sub