以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  MAC问题请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153847)

--  作者:pyh6918
--  发布时间:2020/8/25 12:58:00
--  MAC问题请教
想使用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)

--  作者:有点蓝
--  发布时间:2020/8/25 13:33:00
--  
这种问题自己找3种电脑全部测试一遍就知道了。我也我不知道哪一种稳定
--  作者:pyh6918
--  发布时间:2020/8/25 14:15:00
--  
谢谢