CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Monday, September 25, 2006

Checking Internet connection in .NET

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

///<summary>
///Checks for Internet Connection availability
///</summary>
///<returns>1 for True, 0 for False</returns>
public static int InternetConnectionStatus()
{
bool result = false;
int Desc;
try
{
result = InternetGetConnectedState( out Desc, 0);
}
return Convert.ToInt16(result);
}

Post a Comment