wininet API调用,检测网络

   [DllImport("wininet")]
        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
        /// <summary>
        /// 检查本地的联网状态
        /// </summary>
        /// <returns></returns>
        public static bool CheckNetWorkStatus()
        {
            //return ZC.WPF.General.Extension.ComputerInfoFunction.CheckNetwork.CheckNetworkState();
            int i = 0;
            if (InternetGetConnectedState(out i, 0))
            {
                //已联网
                return true;
            }
            else
            {
                //未联网
                return false;
            }

        }

posted @ 2015-05-28 10:11  DDDF  阅读(311)  评论(0)    收藏  举报