【转】C#检测是否联网
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace LocalApp.ConsoleApp.Core
{
    public class Net
    {
         [DllImport("wininet")]
        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

        /// <summary>
        /// 检测本机是否联网
        /// </summary>
       /// <returns></returns>
        public static bool IsConnectedInternet()
        {
            int i = 0;
            if (InternetGetConnectedState(out i, 0))
            {
                //已联网
                return true;
             }
            else
            {
                //未联网
                return false;
             }

         }

     }
}
【转】C#检测是否联网
【转】C#检测是否联网
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace LocalApp.ConsoleApp.Core
{
    public class Net
    {
         [DllImport("wininet")]
        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

        /// <summary>
        /// 检测本机是否联网
        /// </summary>
       /// <returns></returns>
        public static bool IsConnectedInternet()
        {
            int i = 0;
            if (InternetGetConnectedState(out i, 0))
            {
                //已联网
                return true;
             }
            else
            {
                //未联网
                return false;
             }

         }

     }
}
【转】C#检测是否联网

相关文章:

  • 2021-05-11
  • 2021-09-10
  • 2022-12-23
  • 2021-07-26
  • 2021-08-15
  • 2022-12-23
  • 2021-05-20
猜你喜欢
  • 2021-12-11
  • 2022-12-23
  • 2021-09-26
  • 2021-10-08
  • 2021-08-06
相关资源
相似解决方案