vb.net读取网卡型号 vbnet config文件读取

vb.net怎么获取网卡MAC地址?Public Function EnumNetworkAdapters() As String
Try
Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
Dim mo As New System.Management.ManagementObject
For Each mo In queryCollection
If IsDBNull(mo.Item("Description")) = False Then
EnumNetworkAdapters = mo.Item("Description")"|||"
End If
If IsDBNull(mo.Item("macaddress")) = False Then
If mo.Item("macaddress")"" Then
EnumNetworkAdapters = mo.Item("macaddress")"|||"
End If
End If
If IsDBNull(mo.Item("IPAddress")) = False Then
Dim temp As String
temp = Join(mo.Item("IPAddress"), ".")
If temp"" Then
EnumNetworkAdapters = temp"|||"
End If
End If
Next
Catch err A* **ception
EnumNetworkAdapters = err.Messageerr.StackTrace
End Try
End Function
vb获取网卡mac的完整代码VB获取网卡MAC地址源代码
具体代码vb.net读取网卡型号:(其中GetMACAddress() 函数为楼主所需函数)
Option Explicit
Public CheckCode As Long
Private Const NCBASTATAs Long = H33
Private Const NCBNAMSZAs Integer = 16
Private Const HEAP_ZERO_MEMORYAs Long = H8
Private Const HEAP_GENERATE_EXCEPTIONSAs Long = H4
Private Const NCBRESETAs Long = H32
Private Type NCB
ncb_commandAs Byte
ncb_retcodeAs Byte
ncb_lsnAs Byte
ncb_numAs Byte
ncb_bufferAs Long
ncb_lengthAs Integer
ncb_callnameAs String * NCBNAMSZ
ncb_nameAs String * NCBNAMSZ
ncb_rtoAs Byte
ncb_stoAs Byte
ncb_postAs Long
ncb_lana_numAs Byte
ncb_cmd_cpltAs Byte
ncb_reserve(9)As Byte
ncb_eventAs Long
End Type
Private Type ADAPTER_STATUS
adapter_address(5)As Byte
rev_majorAs Byte
reserved0As Byte
adapter_typeAs Byte
rev_minorAs Byte
durationAs Integer
frmr_recvAs Integer
frmr_xmitAs Integer
iframe_recv_errAs Integer
xmit_abortsAs Integer
xmit_successAs Long
recv_successAs Long
iframe_xmit_errAs Integer
recv_buff_unavailAs Integer
t1_timeoutsAs Integer
ti_timeoutsAs Integer
Reserved1As Long
free_ncbsAs Integer
max_cfg_ncbsAs Integer
max_ncbsAs Integer
xmit_buf_unavailAs Integer
max_dgram_sizeAs Integer
pending_sessAs Integer
max_cfg_sessAs Integer
max_sessAs Integer
max_sess_pkt_sizeAs Integer
name_countAs Integer
End Type
Private Type NAME_BUFFER
nameAs String * NCBNAMSZ
name_numAs Integer
name_flagsAs Integer
End Type
Private Type ASTAT
adaptAs ADAPTER_STATUS
NameBuff(30)As NAME_BUFFER
End Type
Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, _
ByVal hpvSource As Long, _
ByVal cbCopy As Long)
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, _
ByVal dwFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
ByVal dwFlags As Long, _
lpMem As Any) As Long
Public Function GetMAC() As Integer
Dim bRetAs Byte
Dim myNcbAs NCB
Dim myASTAT As ASTAT
Dim pASTATAs Long
Dim intMAC As Integer
myNcb.ncb_command = NCBRESET
bRet = Netbios(myNcb)
With myNcb
.ncb_command = NCBASTAT
.ncb_lana_num = 0
.ncb_callname = "* "
.ncb_length = Len(myASTAT)
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)
End With
If pASTAT = 0 Then
Exit Function
End If
myNcb.ncb_buffer = pASTAT
bRet = Netbios(myNcb)
CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)
intMAC = myASTAT.adapt.adapter_address(0)
intMAC = intMACmyASTAT.adapt.adapter_address(1)
intMAC = intMACmyASTAT.adapt.adapter_address(2)
intMAC = intMACmyASTAT.adapt.adapter_address(3)
intMAC = intMACmyASTAT.adapt.adapter_address(4)
intMAC = intMACmyASTAT.adapt.adapter_address(5)
GetMAC = intMAC
Call HeapFree(GetProcessHeap(), 0, pASTAT)
End Function
Public Function GetMACAddress() As String
Dim bRetAs Byte
Dim myNcbAs NCB
Dim myASTAT As ASTAT
Dim pASTATAs Long
myNcb.ncb_command = NCBRESET
bRet = Netbios(myNcb)
With myNcb
.ncb_command = NCBASTAT
.ncb_lana_num = 0
.ncb_callname = "* "
.ncb_length = Len(myASTAT)
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, .ncb_length)
End With
If pASTAT = 0 Then
Exit Function
End If
myNcb.ncb_buffer = pASTAT
bRet = Netbios(myNcb)
CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)
GetMACAddress = HexEx(myASTAT.adapt.adapter_address(0))"-"HexEx(myASTAT.adapt.adapter_address(1))"-"HexEx(myASTAT.adapt.adapter_address(2))"-"HexEx(myASTAT.adapt.adapter_address(3))"-"HexEx(myASTAT.adapt.adapter_address(4))"-"HexEx(myASTAT.adapt.adapter_address(5))
Call HeapFree(GetProcessHeap(), 0, pASTAT)
End Function
Private Function HexEx(ByVal B As Long) As String
Dim aa As String
aa = Hex$(B)
If Len(aa)2 Then
aa = "0"aa
End If
HexEx = aa
End Function
vb.net 获取局域网计算机的当前用户名和计算机型号等信息Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub GetName()
Dim sJM As String
Dim sMC As String
Dim sIP As String
Dim s As String
s = String(128, Chr(0))
GetComputerName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sJM = s'计算机名称
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘当前用户名称
End Sub
'用这种方法在远程获得再发回本机就可以吧
'取计算机型号暂时不会
vb.net 获取指定网卡的网络连接状态.net不能获得【指定】网卡vb.net读取网卡型号的信息vb.net读取网卡型号 , 给个思路,先遍历所有网卡,然后找到你需要vb.net读取网卡型号的的那个网卡的信息 。
电脑有两张网卡 。如何用vb.net分别获取网卡的IP?求大神明路!'要使得引用System.Management有效vb.net读取网卡型号,先通过菜单
'[项目]--[添加引用]vb.net读取网卡型号,在“.Net”选项卡里vb.net读取网卡型号,选择“System.Management”vb.net读取网卡型号,单击[确定]
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
For Each MySearcherObj As ManagementObject In MySearcher.Get
If CBool(MySearcherObj("IPEnabled")) Then
MsgBox(MySearcherObj("IPAddress")(0))
End If
Next
End Sub
End Class
求大神指点 vb.net 怎么获取 所有网卡的 描述呢? vbs 的也可以Private Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
objWMI = GetObject("winmgmts://"strComputer"/root/cimv2")
colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNothing(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox("IP 地址:"IP.IPAddress(I)Chr(10)_
"网卡类型:"IP.Description(I)Chr(10)_
"网卡地址:"IP.Macaddress(I))
Next
End If
Next
End Sub
【vb.net读取网卡型号 vbnet config文件读取】vb.net读取网卡型号的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vbnet config文件读取、vb.net读取网卡型号的信息别忘了在本站进行查找喔 。

    推荐阅读