📄 testpci.frm
字号:
VERSION 5.00
Begin VB.Form PciForm
Caption = "TVicHW32.DLL 4.0 PCI test example"
ClientHeight = 4995
ClientLeft = 60
ClientTop = 345
ClientWidth = 8715
LinkTopic = "Form1"
ScaleHeight = 4995
ScaleWidth = 8715
StartUpPosition = 3 'Windows Default
Begin VB.Frame Dentry
Caption = "Driver Entry Point"
Height = 1035
Left = 6180
TabIndex = 17
Top = 2340
Width = 2415
Begin VB.OptionButton TVicDevice0
Caption = "TVicDevice0"
Height = 255
Left = 240
TabIndex = 19
Top = 300
Value = -1 'True
Width = 1575
End
Begin VB.OptionButton TVicDevice1
Caption = "TVicDevice1"
Height = 255
Left = 240
TabIndex = 18
Top = 660
Width = 1575
End
End
Begin VB.CommandButton B_Enum
Caption = "Enumerate all PCI devices"
Height = 435
Left = 3420
TabIndex = 10
Top = 3660
Width = 2415
End
Begin VB.ListBox L_Pci
BeginProperty Font
Name = "Courier New"
Size = 8.25
Charset = 204
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3000
Left = 60
TabIndex = 9
Top = 465
Width = 5835
End
Begin VB.CommandButton B_Exit
Caption = "Exit"
Height = 495
Left = 6180
TabIndex = 7
Top = 4320
Width = 2415
End
Begin VB.Frame Frame1
Height = 1455
Left = 6180
TabIndex = 2
Top = 120
Width = 2415
Begin VB.Label Label6
Alignment = 2 'Center
Caption = "mailto: ivi@ufanet.ru"
Height = 255
Left = 120
TabIndex = 6
Top = 1080
Width = 2175
End
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "Copyright (c) Victor Ishikeev"
Height = 255
Left = 120
TabIndex = 5
Top = 840
Width = 2175
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "Shareware v.m. 4.0"
Height = 255
Index = 0
Left = 120
TabIndex = 4
Top = 600
Width = 1935
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "TVicHW32"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 204
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 240
TabIndex = 3
Top = 240
Width = 1935
End
End
Begin VB.CommandButton Close_Driver
Caption = "Close TVicHW32"
Height = 495
Left = 7440
TabIndex = 1
Top = 1740
Width = 1155
End
Begin VB.CommandButton Open_Driver
Caption = "Open TVicHW32"
Height = 495
Left = 6180
TabIndex = 0
Top = 1740
Width = 1155
End
Begin VB.Label L_Dev
Caption = "?"
Height = 255
Left = 2400
TabIndex = 16
Top = 4500
Width = 435
End
Begin VB.Label L_Mech
Caption = "?"
Height = 255
Left = 2400
TabIndex = 15
Top = 4080
Width = 435
End
Begin VB.Label L_Buses
Caption = "?"
Height = 255
Left = 2400
TabIndex = 14
Top = 3660
Width = 315
End
Begin VB.Label Label8
Caption = "Number of PCI devices:"
Height = 255
Left = 480
TabIndex = 13
Top = 4500
Width = 1815
End
Begin VB.Label Label7
Caption = "Hardware mechanism: "
Height = 255
Left = 480
TabIndex = 12
Top = 4080
Width = 1755
End
Begin VB.Label Label2
Caption = "PCI buses detected: "
Height = 255
Left = 480
TabIndex = 11
Top = 3660
Width = 1815
End
Begin VB.Label Label1
Caption = "BusDevFun Class VendorID DeviceID HeaderType BaseAddr"
Height = 315
Left = 120
TabIndex = 8
Top = 120
Width = 5775
End
End
Attribute VB_Name = "PciForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim HW32 As Long
Dim ActiveHW As Boolean
Private Sub B_Enum_Click()
Dim buses As Integer, n As Integer, bus As Integer, dev As Integer, func As Integer
Dim Info As PciNonBridge
Dim Info1 As PciBridge
Dim Info2 As PciCardBus
Dim b As Byte, d As Byte, f As Byte
Dim Res As Long
Dim s As String
L_Pci.Clear
buses = GetLastPciBus(HW32)
L_Buses.Caption = buses + 1
L_Mech.Caption = GetHardwareMechanism(HW32)
n = 0
If (buses >= 0) Then
For bus = 0 To buses
For dev = 0 To 31
For func = 0 To 7
b = bus
d = dev
f = func
Res = GetPciDeviceInfo(HW32, bus, dev, func, Info)
If (Res <> 0) And (Info.vendorID <> &HFFFF) And (Info.deviceID <> &HFFFF) Then
n = n + 1
s = IntToHex2(b) + "/" + IntToHex2(d) + "/" + IntToHex2(f)
s = s + " " + IntToHex2(Info.classcode) + " " + IntToHex4(Info.vendorID) + " " + IntToHex4(Info.deviceID)
s = s + " " + IntToHex2(Info.header_type And &HF) + "=>"
If Info.header_type = 0 Then 'Non-bridge PCI configuration
s = s + "non-bridge " + IntToHex8(Info.base_address0)
End If
If Info.header_type = 1 Then 'PCI-PCI bridge configuration
Call CopyMemory(Info1, Info, 256)
s = s + "bridge " + IntToHex8(Info1.base_address0)
End If
If Info.header_type > 1 Then 'PCI CardBus configuration
Call CopyMemory(Info2, Info, 256)
s = s + "CardBus " + IntToHex8(Info2.memory_base0)
End If
L_Pci.AddItem (s)
If ((Info.header_type And &H80) = 0) And (func = 0) Then GoTo 100
End If
Next func
100
Next dev
Next bus
End If
L_Dev.Caption = n
End Sub
Private Sub B_Exit_Click()
If ActiveHW Then HW32 = CloseTVicHW32(HW32)
ActiveHW = False
Unload PciForm
End Sub
Private Sub Close_Driver_Click()
HW32 = CloseTVicHW32(HW32)
Open_Driver.Enabled = True
Close_Driver.Enabled = False
ActiveHW = False
B_Enum.Enabled = False
End Sub
Private Sub Form_Load()
HW32 = 0
ActiveHW = False
Open_Driver.Enabled = True
Close_Driver.Enabled = False
B_Enum.Enabled = False
End Sub
Private Sub Open_Driver_Click()
HW32 = 0
If TVicDevice0 Then
HW32 = OpenTVicHW32(HW32, "TVICHW32", "TVicDevice0")
Else
HW32 = OpenTVicHW32(HW32, "TVICHW32", "TVicDevice1")
End If
If GetActiveHW(HW32) Then
Open_Driver.Enabled = False
Close_Driver.Enabled = True
B_Enum.Enabled = True
ActiveHW = True
Else
Call MsgBox("Can't open the driver!", 0, "Warning!")
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -