Wednesday, June 1, 2011

check internet connectivity using c#

using System ;
using System.Runtime ;
using System.Runtime.InteropServices ;
public class InternetClass
{
//Creating the extern function for checking internet connection.
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue) ;
//Creating a function that uses the API function to check internet connection.
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState(out Desc, 0) ;
}
}

No comments:

Post a Comment