VB获取网卡MAC运行时出错是因为Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
Set objWMI = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colIP = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IP.ipaddress) Then
For I = LBound(IP.ipaddress) To UBound(IP.ipaddress)
Mac = IP.macaddress(I)
Descrip = IP.Description(I)
'MsgBox "IP 地址:" & IP.ipaddress(I) & Chr(10) & _
没有运行正确。
1)机器上需要安装vb runtime,可以去微软下载
2)winsock控件,需要注册,用“regsvr32 文件路径”