发布网友 发布时间:2024-10-23 22:07
共1个回答
热心网友 时间:2024-10-30 20:32
Private Sub Form_Load() Dim Mac strComputer = "." Mac = "" '获得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 TeMac.Text = Replace(Trim(Mac), ":", "-") 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)objObject.DNSHostName If Ip.ipaddress(i) = "0.0.0.0" Then Else TeIp.Text = Trim(TeIp.Text + " " + Ip.ipaddress(i)) End If 'MsgBox "IP 地址:" & IP.ipaddress(I) & Chr(10) & _ "网卡类型:" & IP.Description(I) & Chr(10) & _ "网卡地址:" & IP.macaddress(I) Next End If Next End Sub