以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何获取本机的网关地址?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=53030)

--  作者:ap9709130
--  发布时间:2014/6/27 17:47:00
--  如何获取本机的网关地址?
如题:有谁有相关的代码?多谢!
--  作者:有点甜
--  发布时间:2014/6/27 18:10:00
--  

要引用一下System.management.dll

 

Dim query As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
Dim queryCollection As System.Management.ManagementObjectCollection = query.Get()
Dim mo As New System.Management.ManagementObject
For Each mo In queryCollection
    If Convert.ToBoolean(mo("ipEnabled")) = True
        If mo("DefaultIPGateway") IsNot Nothing Then          
            MessageBox.Show( mo("DefaultIPGateway")(0))
        End If
    End If
Next

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140627180951.png
图片点击可在新窗口打开查看