VERSION 5.00 Begin VB.Form Form1 BorderStyle = 3 'Fixed Dialog Caption = "Sample 2" ClientHeight = 5445 ClientLeft = 1635 ClientTop = 1680 ClientWidth = 6405 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 5445 ScaleWidth = 6405 ShowInTaskbar = 0 'False StartUpPosition = 2 'CenterScreen Begin VB.TextBox BaseBox Height = 300 Left = 1770 TabIndex = 0 Text = "300" Top = 1020 Visible = 0 'False Width = 735 End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1 Left = 5400 Top = 840 End Begin VB.CommandButton ExitButton Caption = "E&xit" Height = 495 Left = 5040 TabIndex = 21 Top = 2520 Width = 1215 End Begin VB.CommandButton TestButton Caption = "&Test" Height = 495 Left = 5040 TabIndex = 20 Top = 1800 Width = 1215 End Begin VB.CheckBox Bit7 Caption = "When checked, an INT has occured" Height = 195 Left = 360 TabIndex = 16 Top = 4440 Width = 4335 End Begin VB.CheckBox Bit6 Caption = "When unchecked, voltage is too low (OPTION 1)" Height = 195 Left = 360 TabIndex = 15 Top = 4200 Width = 4335 End Begin VB.CheckBox Bit5 Caption = "When unchecked, voltage is too high (OPTION 1)" Height = 195 Left = 360 TabIndex = 14 Top = 3960 Width = 4335 End Begin VB.CheckBox Bit4 Caption = "When checked, fan speed is okay (OPTION 4)" Height = 195 Left = 360 TabIndex = 13 Top = 3720 Width = 4335 End Begin VB.CheckBox Bit3 Caption = "Isolated digital input #1 (OPTION 4)" Height = 195 Left = 360 TabIndex = 12 Top = 3480 Width = 4335 End Begin VB.CheckBox Bit2 Caption = "Isolated digital input #0 (OPTION 4)" Height = 195 Left = 360 TabIndex = 11 Top = 3240 Width = 4335 End Begin VB.CheckBox Bit1 Caption = "When unchecked, temperature is too high (OPTION 2)" Height = 195 Left = 360 TabIndex = 10 Top = 3000 Width = 4335 End Begin VB.CheckBox Bit0 Caption = "When unchecked, CTR1 has timed out" Height = 195 Left = 360 TabIndex = 9 Top = 2760 Width = 4335 End Begin VB.Label Label9 Height = 225 Left = 2865 TabIndex = 24 Top = 1080 Width = 2415 End Begin VB.Label Label12 Height = 255 Left = 4920 TabIndex = 23 Top = 4200 Width = 375 End Begin VB.Label Label11 Height = 255 Left = 4920 TabIndex = 22 Top = 3960 Width = 375 End Begin VB.Label Label10 Caption = "degrees Fahrenheit" Height = 255 Left = 2640 TabIndex = 19 Top = 4920 Width = 1455 End Begin VB.Label TemperatureLabel Caption = "000" Height = 255 Left = 1440 TabIndex = 18 Top = 4920 Width = 1095 End Begin VB.Label Label8 Caption = "Temperature:" Height = 255 Left = 360 TabIndex = 17 Top = 4920 Width = 975 End Begin VB.Label Label7 Caption = "Hit the test key to start and the Exit key to exit" Height = 270 Left = 360 TabIndex = 8 Top = 2235 Width = 3405 End Begin VB.Label Label6 Caption = "Note that some functions require options to be installed" Height = 240 Left = 360 TabIndex = 7 Top = 1920 Width = 4230 End Begin VB.Label Label5 Caption = "Temperature at BASE+4 and BASE+5, respectively" Height = 270 Left = 345 TabIndex = 6 Top = 1680 Width = 3690 End Begin VB.Label Label4 Caption = "This program demonstrates how to read the Control Register and" Height = 225 Left = 360 TabIndex = 5 Top = 1425 Width = 4725 End Begin VB.Label BaseLabel Height = 225 Left = 1545 TabIndex = 4 Top = 1080 Width = 810 End Begin VB.Label Label3 Caption = "Base Address:" Height = 270 Left = 375 TabIndex = 3 Top = 1065 Width = 1080 End Begin VB.Label Label2 Caption = "Reading Control Register and Temperature" Height = 225 Left = 1680 TabIndex = 2 Top = 675 Width = 3285 End Begin VB.Label Label1 Caption = "Windows 95/NT PCI-WDG-CSM SAMPLE 2" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 390 Left = 420 TabIndex = 1 Top = 135 Width = 5460 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Function InPortB Lib "ACCES32.dll" Alias "VBInPortB" (ByVal Port As Long) As Integer Private Declare Function OutPortB Lib "ACCES32.dll" Alias "VBOutPortB" (ByVal Port As Long, ByVal Value As Byte) As Integer Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const KEY_QUERY_VALUE = &H1 Private Type TPCI_COMMON_CONFIG VendorID As Integer DeviceID As Integer Command As Integer Status As Integer RevisionID As Byte ProgIf As Byte SubClass As Byte BaseClass As Byte CacheLineSize As Byte LatencyTimer As Byte HeaderType As Byte BIST As Byte Addressesses(5) As Long Reserved1(1) As Long RomAddressess As Long Reserved2(1) As Long InterruptLine As Byte InterruptPin As Byte MinimumGrant As Byte MaximumLatency As Byte End Type Dim Buf(63) As TPCI_COMMON_CONFIG Public Address As Long Public Running As Boolean Public Found As Boolean Private Sub ExitButton_Click() Timer1.Enabled = False End End Sub Private Sub Form_Load() 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 Found = False Call RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\PCIFIND\NTioPCI\Parameters", 0, KEY_QUERY_VALUE, hKey) DataSize = 4 Num& = 0 Call RegQueryValueEx(hKey, "NumDevices", 0, DataType, Num, DataSize) If (Num = 0) Then GoTo NoCards DataSize = 64 * 64 Call RegQueryValueEx(hKey, "PCICommonConfig", 0, DataType, Buf(0), DataSize) For i = 0 To Num - 1 Step 1 If Found Then Exit For temp = Hex(Buf(i).DeviceID) If (Buf(i).DeviceID = &H22C0) And (Buf(i).VendorID = &H494F) Then Address = Buf(i).Addressesses(2) And &HFFF8 BaseLabel.Caption = Hex(Address) Found = True End If Next i NoCards: If Not Found Then BaseBox.Visible = True Label1.Caption = "Windows95/NT WDG-CSM Sample 2" Label9.Caption = "PCI-WDG-CSM Not Found" Bit4.Caption = "When unchecked, fan speed is okay (OPTION 4)" Bit7.Caption = "When unchecked, an INT has occured." End If RegCloseKey (hKey) End Sub Private Sub TestButton_Click() If Not Found Then Address = "&H" + BaseBox.Text End If Timer1.Enabled = True End Sub Private Sub Timer1_Timer() readback = InPortB(Address + 4) Label12.Caption = Hex(readback) Bit0.Value = 0 Bit1.Value = 0 Bit2.Value = 0 Bit3.Value = 0 Bit4.Value = 0 Bit5.Value = 0 Bit6.Value = 0 Bit7.Value = 0 If ((readback And 1) = 1) Then Bit0.Value = 1 If ((readback And 2) = 2) Then Bit1.Value = 1 If ((readback And 4) = 4) Then Bit2.Value = 1 If ((readback And 8) = 8) Then Bit3.Value = 1 If ((readback And 16) = 16) Then Bit4.Value = 1 If ((readback And 32) = 32) Then Bit5.Value = 1 If ((readback And 64) = 64) Then Bit6.Value = 1 If ((readback And 128) = 128) Then Bit7.Value = 1 readback = InPortB(Address + 5) Label11.Caption = Hex(readback) TemperatureLabel.Caption = Str((((readback * (11 / 15))) + 7)) ' Temperature is simply ((BASE+5) * 11/15) + 7} End Sub