當前位置:成語大全網 - 書法字典 - 用VB獲取MAC地址

用VB獲取MAC地址

私有子窗體_Load()

昏暗的蘋果電腦

strComputer =“。“

Mac =““

獲取MAC信息

set objWMIService = GetObject(“winmgmts:“& amp;“{ impersonation level = impersonate }!///& amp;str計算機& amp“/root/cimv2“)““添加此。

Set colItems = objWMIService。ExecQuery(“Select * from Win32 _ NetworkAdapterConfiguration Where IPEnabled = TRUE“)

對於列中的每個對象

Mac = Mac+““+objitem . Mac address

然後

TeMac。text = Replace(Trim(Mac),“:“,“-“)

strComputer =“。“

set obj wmi = GetObject(“winmgmts:///“& amp;str計算機& amp“/root/cimv2“)

Set colIP = objWMI。ExecQuery(“Select * from Win32 _ NetworkAdapterConfiguration where IPEnabled = TRUE“)

對於colIP中的每個Ip

如果不為空(Ip.ipaddress),則

對於I = LBound(IP . IP address)到UBound(IP . IP address)

MAC = IP . MAC address(I)obj object。DNSHostName

如果IP . IP address(I)=“0 . 0 . 0 . 0”,則

其他

TeIp。text = Trim(TeIp。text+““+IP . IP address(I))

如果…就會結束

MsgBox“IP地址:“&;IP地址(I)和chr(10)和amp_

“網卡類型:“&;IP。描述(壹)和chr(10)和amp_

“網卡地址:“&;IP . MAC地址(壹)

然後

如果…就會結束

然後

末端接頭