VB 如何获取winxp,win7及以上版本各种网卡的地址
如题,网络上也有获取本机网卡地址的现成模块,但测试后有发现,在win7下获取的网卡地址为00-00-00-00-00-00,在winxp下,有时获取的网卡也为00-00-00-00-00-00;当未联网时,获取的网卡地址也为00-00-00-00-00-00.有什么模块,能够获取各个操作系统不同版本,不同网卡,在未联网下,网卡的正确地址? VB?网卡地址
[解决办法]
可以试试……
Private Function GetMacAddress() As String
Dim iObs As Object
Dim iObj As Object
Set iObs = GetObject("Winmgmts:").ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True")
If iObs Is Nothing Then Exit Function
For Each iObj In iObs
GetMacAddress = iObj.MACAddress
Next
Set iObs = Nothing
Set iObj = Nothing
End Function
Shell "ipconfig >ipconfig.txt",vbHide
'然后读文件ipconfig.txt的内容