测试与指定IP 通讯状态
using System.Management;
引用 System.Management;
//测试网络连通
public static bool Ping(string Target)
{
SelectQuery query = new SelectQuery("Win32_PingStatus", string.Format("Address='{0}'", Target));
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject result in searcher.Get())
{
return (result["StatusCode"] != null && (0 == (UInt32)result["StatusCode"]));
}
return false;
}