[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

博客展示了一段代码,通过调用 wininet.dll 中的 InternetGetConnectedState 方法来检测本地系统的网络连接状态。代码定义了 IsConnected 方法,返回布尔值表示是否有网络连接,还提及了相关参考资料。
934

被折叠的 条评论
为什么被折叠?



