[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);
}
检测本地计算机是否连上Internet
最新推荐文章于 2021-07-24 00:33:48 发布
本文介绍了一个简单的方法来检查本地系统的互联网连接状态。通过调用 wininet.dll 库中的 InternetGetConnectedState 函数,可以实现判断当前是否有互联网连接的功能。
349

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



