检测本地计算机是否连上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);
}

References:
Microsoft Offline Application Block
WinINetDetectionStrategy.cs
posted @ 2005-04-20 04:56  黎波  阅读(1346)  评论(3编辑  收藏  举报