2018-3-27
14:19

root
root

[程序代码]取本机Mac相关信息

'代码出处:http://zhidao.baidu.com/question/155475470.html
Private Sub Form_Load()
Dim Mac
strComputer = "."
Mac = ""

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each objItem In colItems
Mac = Mac + " " + objItem.macaddress
Next

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)
Text1.Text = Ip.ipaddress(I)   '取内网IP地址
Text2.Text = Ip.Description(I) '取网卡类型
Text3.Text = Ip.macaddress(I)  '取MAC地址
Next

End If

Next
End Sub

文章如需转载请注明:转载自: 紫灵幽梦
« 上一篇 下一篇 »

发表留言: