VB 知道网卡名称如何获取相应本地连接的名称??? 知道 网卡名称 IP地址 MAC地址
Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller - 数据包计划程序微型端口 如何 得到该网卡的 本地连接的名称 如 本地连接 2
Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller - 数据包计划程序微型端口 如何 得到该网卡的 本地连接的名称 如 本地连接 2
Dim myNcb As NCB
Dim bRet As Byte
myNcb.ncb_command = NCBRESET
bRet = Netbios(myNcb)
myNcb.ncb_command = NCBASTAT
myNcb.ncb_lana_num = 0
myNcb.ncb_callname = "* "
Dim myASTAT As ASTAT, tempASTAT As ASTAT
Dim pASTAT As Long
myNcb.ncb_length = Len(myASTAT)
Debug.Print Err.LastDllError
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, myNcb.ncb_length)
If pASTAT = 0 Then
Debug.Print "memory allcoation failed!"
Exit Sub
End If
myNcb.ncb_buffer = pASTAT
bRet = Netbios(myNcb)
Debug.Print Err.LastDllError
CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)
MsgBox Hex(myASTAT.adapt.adapter_address(0)) & " " & Hex(myASTAT.adapt.adapter_address(1)) _
& " " & Hex(myASTAT.adapt.adapter_address(2)) & " " _
& Hex(myASTAT.adapt.adapter_address(3)) _
& " " & Hex(myASTAT.adapt.adapter_address(4)) & " " _
& Hex(myASTAT.adapt.adapter_address(5)), vbOKOnly, "网卡地址"
HeapFree GetProcessHeap(), 0, pASTAT
End Sub
'--------------------------------------------------------------------------------
' 工程 : GIS_PROJECT
' 过程名 : getLocalHostInfo
' 类型 : Function
' 说明 : []
' 创建人 :
' 注释人 :
' Machine : DR-L
' 时间 : 1-30-2008-11:43:47
'
' 参数列表 : ) (IPInfo()
'--------------------------------------------------------------------------------
'</CSCM>
Public Function getLocalHostInfo() As Variant '<EhHeader>
On Error GoTo getLocalHostInfo_Err '</EhHeader> Dim regKey As String
Dim regKeys() As String
Dim keysNum As Long
Dim i As Integer, j As Integer
Dim strIP As String
Dim strMask As String
Dim arrIP() As String
Dim arrMask() As String
Dim tmp As String
Dim rt As Long
Dim regTemp(255) As String
Dim ipNum As Integer
Dim tIpinfo() As String
100 ReDim tIpinfo(0)102 With myRegistry
104 .ClassKey = HKEY_LOCAL_MACHINE
106 .SectionKey = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
108 .EnumerateSections regKeys, keysNum110 For i = 1 To keysNum
112 .SectionKey = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & regKeys(i)
114 .ValueKey = "IPAddress"
116 strIP = .Value118 If strIP <> "0.0.0.0" And strIP <> "" And LCase(strIP) <> "error" And strIP <> "" Then
120 ReDim Preserve tIpinfo(ipNum)
122 .ValueKey = "SubnetMask"
124 strMask = .Value126 If InStr(strIP, Chr(0)) > 0 Then
128 arrIP = Split(strIP, Chr(0))
130 arrMask = Split(strMask, Chr(0))132 For j = 0 To safeUbound(arrIP)
134 tmp = Replace(Trim(arrIP(j)), vbCrLf, "")136 If tmp <> "" Then
138 tIpinfo(UBound(tIpinfo)) = tmp
140 tmp = Replace(Trim(arrMask(j)), vbCrLf, "")
142 'tIpinfo(UBound(tIpinfo)).SubNetMask = tmp
End If144 Next j Else
146 tIpinfo(UBound(tIpinfo)) = strIP
148 'tIpinfo(UBound(tIpinfo)).SubNetMask = strMask
End If150 ipNum = ipNum + 1
End If152 Next i End With154 getLocalHostInfo = tIpinfo '<EhFooter> GoTo FunctionEndgetLocalHostInfo_Err:
err.Raise vbObjectError + 100, "clsLog.getLocalHostInfo", err.Description & vbCrLf & "clsLog.getLocalHostInfo Error by " & Erl & " Line"
FunctionEnd: '</EhFooter>End Function