110,534
社区成员
发帖
与我相关
我的任务
分享
[System.Runtime.InteropServices.DllImport("winInet.dll")]
private extern static bool InternetCheckConnection(String url, int flag, int ReservedValue);
if (InternetCheckConnection("http://www.baidu.com", 1, 0))
{
//联网
}
#region 网络状况判断
[DllImport("winInet.dll ")] //判断联网状态
private static extern bool InternetGetConnectedState(ref int Description, int ReservedValue);
static int Description;//返回值,指示网络状态
#endregion
using System.Net.NetworkInformation;
bool isOk = new Ping().Send("192.16.1.1", 100).Status == IPStatus.Success;