[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 方法来检测本地系统的网络连接状态。若有网络连接返回 True,否则返回 False,还提及了相关参考资料。
930

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



