Search This Blog

Sunday, 1 May 2011

How to know if your machine is connected to internet

using System ;
using System.Runtime ;
using System.Runtime.InteropServices ;

public class InternetConnectionChecker
{

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

    public static bool IsMachineConnectedToInternet( )
    {
        int desc ;
        return InternetGetConnectedState( out desc, 0 ) ;
    }
}

No comments:

Post a Comment