判断计算机当前的网络是否连接

80酷酷网    80kuku.com

  网络

using System.Runtime.InteropServices;
[DllImport("wininet.dll")]

        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

private static bool IsConnected()
        {

            int I = 0;

            bool state = InternetGetConnectedState(out I, 0);

            return state;

        }

        static void Main(string[] args)
        {
            Console.WriteLine(IsConnected().ToString());
        }

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: