测试与指定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;
        }

posted @ 2009-09-24 10:40  迪卡.凯恩  阅读(230)  评论(0编辑  收藏  举报