要引用一下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