VERSION 5.00 Begin VB.Form Sample1Form Caption = "Sample 1" ClientHeight = 5535 ClientLeft = 6330 ClientTop = 5955 ClientWidth = 6555 LinkTopic = "Form1" ScaleHeight = 369 ScaleMode = 3 'Pixel ScaleWidth = 437 Begin VB.ComboBox deviceListCombo Height = 315 ItemData = "Sample1u.frx":0000 Left = 1320 List = "Sample1u.frx":0002 TabIndex = 14 Text = "Combo1" Top = 3360 Width = 3735 End Begin VB.Frame Frame1 Caption = "Output" Height = 960 Left = 120 TabIndex = 7 Top = 2124 Width = 6276 Begin VB.Label Label3 Alignment = 2 'Center Caption = "Port 0" Height = 192 Left = 240 TabIndex = 13 Top = 240 Width = 1788 End Begin VB.Label Label5 Alignment = 2 'Center Caption = "Port 2" Height = 192 Left = 4320 TabIndex = 12 Top = 240 Width = 1788 End Begin VB.Label Label4 Alignment = 2 'Center Caption = "Port 1" Height = 192 Left = 2280 TabIndex = 11 Top = 240 Width = 1788 End Begin VB.Label PortPanel Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "0000000000000000" Height = 252 Index = 1 Left = 2280 TabIndex = 10 Top = 480 Width = 1788 End Begin VB.Label PortPanel Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "0000000000000000" Height = 252 Index = 2 Left = 4320 TabIndex = 9 Top = 480 Width = 1788 End Begin VB.Label PortPanel Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "0000000000000000" Height = 252 Index = 0 Left = 240 TabIndex = 8 Top = 480 Width = 1788 End End Begin VB.Timer TestTimer Enabled = 0 'False Interval = 500 Left = 5880 Top = 3360 End Begin VB.Frame BaseAddressBox Caption = "Base Address for ISA Card" Height = 768 Left = 300 TabIndex = 4 Top = 4260 Width = 2256 Begin VB.TextBox BaseEdit Height = 288 Left = 1200 TabIndex = 6 Text = "300" Top = 320 Width = 852 End Begin VB.Label Label2 Caption = "Base Address:" Height = 192 Left = 120 TabIndex = 5 Top = 360 Width = 1068 End End Begin VB.CommandButton ExitButton Caption = "Exit Program" Height = 372 Left = 4800 TabIndex = 3 Top = 4530 Width = 1440 End Begin VB.CommandButton TestButton Caption = "Start Test" Height = 372 Left = 2880 TabIndex = 2 Top = 4530 Width = 1440 End Begin VB.TextBox Text1 BackColor = &H8000000F& Height = 1668 Left = 120 Locked = -1 'True MultiLine = -1 'True TabIndex = 1 Text = "Sample1u.frx":0004 Top = 360 Width = 6276 End Begin VB.Label Label1 Alignment = 2 'Center AutoSize = -1 'True Caption = "IDO-48" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 300 Left = 2835 TabIndex = 0 Top = 0 Width = 780 End End Attribute VB_Name = "Sample1Form" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Function InPortB Lib "ACCES32" Alias "VBInPortB" (ByVal Port As Long) As Integer Private Declare Function OutPortB Lib "ACCES32" Alias "VBOutPortB" (ByVal Port As Long, ByVal Value As Byte) As Integer Dim addresses(0 To 63) As Long Dim Address As Integer Dim data As Long Private Sub deviceListCombo_Click() BaseEdit.Text = Hex(addresses(deviceListCombo.ListIndex)) End Sub Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() data = 1 Dim hKey As Long, dataSize As Long, datatype As Long, n As Long, I As Long, cardsFound As Long Dim Buf(0 To 63) As TPCI_COMMON_CONFIG If (InPortB(&H61) = &HAA55) Then Call MsgBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", 0, "Warning") End If RegOpenKeyEx HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\NTioPCI\Parameters", 0, KEY_QUERY_VALUE, hKey dataSize = 4 cardsFound = 0 RegQueryValueEx hKey, "NumDevices", 0, datatype, cardsFound, dataSize If cardsFound > 0 Then dataSize = 64 * 64 RegQueryValueEx hKey, "PCICommonConfig", 0, datatype, Buf(0), dataSize End If numCards = 0 For I = 0 To cardsFound - 1 If Buf(I).VendorID = &H494F Then Select Case Buf(I).DeviceID Case &H520 deviceListCombo.AddItem Str(numCards) + ": PCI-IDO-48", numCards addresses(numCards) = Buf(I).BaseAddresses(2) And &HFFF8 numCards = numCards + 1 Case &H508 deviceListCombo.AddItem Str(numCards) + ": PCI-IDO-16A", numCards addresses(numCards) = Buf(I).BaseAddresses(2) And &HFFF8 numCards = numCards + 1 Case &H518 deviceListCombo.AddItem Str(numCards) + ": PCI-IDO-32A", numCards addresses(numCards) = Buf(I).BaseAddresses(2) And &HFFF8 numCards = numCards + 1 Case &H521 deviceListCombo.AddItem Str(numCards) + ": PCI-IDO-48A", numCards addresses(numCards) = Buf(I).BaseAddresses(2) And &HFFF8 numCards = numCards + 1 End Select End If Next I deviceListCombo.AddItem "ISA-ID0-48 (Enter Address Below)" addresses(numCards) = &H300 numCards = numCards + 1 deviceListCombo.ListIndex = 0 baseAddress = addresses(0) BaseEdit.Text = Hex(addresses(deviceListCombo.ListIndex)) inByte = 0 outByte = 0 End Sub Private Sub TestButton_Click() If TestTimer.Enabled Then TestTimer.Enabled = False TestButton.Caption = "Start Test" BaseEdit.Enabled = True Else TestTimer.Enabled = True TestButton.Caption = "Abort Test" Address = "&h" + Sample1Form.BaseEdit.Text BaseEdit.Enabled = False End If ' end if/else End Sub Private Sub TestTimer_Timer() Dim Port, I As Integer Dim output As Long Dim mask As Long Dim ofs 'As Integer ofs = Array(0, 1, 2, 4, 5, 6) ' Table of offsets to input registers PortPanel(0).Caption = "" PortPanel(1).Caption = "" PortPanel(2).Caption = "" For Port = 0 To 2 ' Read the 16 input channels of current port ' data = (InPortB(Address + ofs(2 * Port)) And &HFF) ' data = data + (InPortB(Address + ofs((2 * Port) + 1)) And &HFF) OutPortB Address + ofs(2 * Port), data OutPortB Address + ofs(2 * Port + 1), data output = data Or (data * 256) ' Check the status of each bit field and display result mask = 1 For I = 0 To 15 If (mask And output) Then PortPanel(Port).Caption = "1" + PortPanel(Port).Caption Else PortPanel(Port).Caption = "0" + PortPanel(Port).Caption End If mask = mask * 2 Next ' end for i Next ' end for port data = data * 2 If data > 128 Then data = 1 End If End Sub