using System.Runtime.InteropServices; [DllImport("winInet.dll")] private static extern bool InternetGetConnectedState(ref int dwFlag, int dwReserved); private const int INTERNET_MODEM = 1; private const int INTERNET_LAN = 2; public void InetConnectStat() { System.Int32 dwFlag = new int(); if (!InternetGetConnectedState(ref dwFlag, 0)) { Console.WriteLine("Error, Internet Not Connected!"); } else { if ((dwFlag & INTERNET_MODEM) != 0) Console.WriteLine("Internet speed maybe slow."); else { if ((dwFlag & INTERNET_LAN) != 0) Console.WriteLine("Internet Connected!"); } } }