您的位置:首页 > 编程语言 > C#

C# 判断是否联网

2016-03-10 14:31 363 查看
public static class Internet
{
[DllImport("winInet.dll")]
private static extern bool InternetGetConnectedState(ref int dwFlag, int dwReserved);

/// <summary>
/// 返回网络状态
/// </summary>
public static bool Status
{
get
{
Int32 dwFlag = new int();
if (!InternetGetConnectedState(ref dwFlag, 0))
{
return false;
}
else
{
return true;
}
}
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: