c# 获取Ip网关方法2
时间:2010-08-22 来源:jinyuttt
要加入mengment的引用在.net框架中。
主要代码:
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection nics = mc.GetInstances();
foreach (ManagementObject nic in nics)
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
this.textBox1.Text = (nic["IPAddress"] as string[])[0];
this.textBox2.Text = (nic["IPSubnet"] as string[])[0];
this.textBox3.Text = (nic["DefaultIPGateway"] as string[])[0];
}
}
相关阅读 更多 +