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;
            }

        }

你可能感兴趣的:(api)