65.9K
CodeProject is changing. Read more.
Home

Checking Internet Is Connected Or Not From .NET

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.87/5 (32 votes)

Jan 5, 2010

CPOL
viewsIcon

27540

For C# guys....using System ;using System.Runtime ;using System.Runtime.InteropServices ;public class Internet{ [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( out int Description, int ReservedValue ) ; public static bool...

For C# guys....
using System ;
using System.Runtime ;
using System.Runtime.InteropServices ;

public class Internet
{

    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState( out int Description, int ReservedValue ) ;

    public static bool IsConnectedToInternet( )
    {
        int Desc ;
        return InternetGetConnectedState( out Desc, 0 ) ;
    }
}