检测本地计算机是否连上Internet
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
/// <summary>
/// Retrieves the connected state of the local system.
/// </summary>
/// <returns>Returns True if there is an Internet connection, or False otherwise.</returns>
public bool IsConnected()
{
int connectionDescription = 0;
return InternetGetConnectedState(out connectionDescription, 0);
}
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
/// <summary>
/// Retrieves the connected state of the local system.
/// </summary>
/// <returns>Returns True if there is an Internet connection, or False otherwise.</returns>
public bool IsConnected()
{
int connectionDescription = 0;
return InternetGetConnectedState(out connectionDescription, 0);
}
References:
Microsoft Offline Application Block
WinINetDetectionStrategy.cs