以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  获取 Mac、IP、计算机名称  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150628)

--  作者:tld
--  发布时间:2020/6/3 12:38:00
--  获取 Mac、IP、计算机名称
老师,如何用foxtable获取本机电脑的 Mac、IP、计算机名称?谢谢!
--  作者:有点蓝
--  发布时间:2020/6/3 13:48:00
--  
Dim IPAdress As System.Net.IPAddress
Dim HostName As String
HostName = System.Net.Dns.GetHostName \'获得本机的机器名
IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.GetValue(0) \'获得本机的IP
messagebox.show(IPAdress.Tostring) \'获得MAC地址
msgbox(HostName)

‘’外部引用添加:System.Management.dll
Dim mc As new System.Management.ManagementClass("Win32_NetworkAdapterConfiguration")

Dim moc = mc.GetInstances()
For Each  mo As object In moc
    If mo("IPEnabled").ToString() = "True"
       msgbox( mo("MacAddress").ToString())
    End If
Next