标签:
public List<string> GetDns(string ClientIP,ref int NetworkAdapterCount) { List<string> ls = new List<string>(); string strClass = "Win32_NetworkAdapterConfiguration"; ManagementObjectCollection moc = GetMOCbyWMI(ClientIP, strClass); foreach (ManagementObject mo in moc) { if (!(bool)mo["IPEnabled"]) continue; string[] adss = mo["IPAddress"] as string[]; bool NetADFlag = false; NetworkAdapterCount++; foreach (string ads in adss) { if (ads.StartsWith("10.")) { NetADFlag = true; break; } } if (!NetADFlag) { continue; } string[] values = mo["DNSServerSearchOrder"] as string[]; if (values == null || values.Length == 0) { ls.Add("获取DNS失败,请登录服务器检查网卡"); } else { for (int i = 0; i < values.Length; i++) { ls.Add(values[i]); } } } return ls; }
标签:
原文地址:http://www.cnblogs.com/sherlock99/p/4338079.html