后台:

        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(int description, int reservedValue);
        /// <summary>
        /// 判断当前网络状况
        /// </summary>
        /// <returns></returns>
        public static bool IsConnectedToInternet()
        {
            return InternetGetConnectedState(0, 0);
        }

调用:

       if (!WebHelper.IsConnectedToInternet())
         {
               MessageBox("网络连接中断,请检查网络状态!");
                return;
         }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2021-07-26
  • 2022-02-03
  • 2021-06-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案