想使用MAC码作为注册依据,在论坛查了一下,发现了好几种获取MAC的方法,我只会使用,不懂原理,不知道哪种方法稳定并适合W7、W8、W10,请指教?
1:
Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SEL ECT * FR OM Win32_NetworkAdapterConfiguration")
Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
Dim mo As New System.Management.ManagementObject
For Each mo In queryCollection
If IsDBNull(mo.Item("macaddress")) = False Then
If mo.Item("macaddress") <> "" AndAlso mo.Item("IPEnabled") Then
output.show(mo.Item("macaddress"))
End If
End If
Next
2:
Dim nics() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
output.show(nics(0).GetPhysicalAddress.Tostring) '获得MAC地址
output.show(nics.length)