您的位置:首页 > 理论基础 > 计算机网络

C# 判断计算机网络是否可用

2008-07-18 11:25 330 查看
using System.Runtime.InteropServices;
代码:

[DllImport("wininet.dll")]

private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

private static bool IsConnected()
{

int I = 0;

bool state = InternetGetConnectedState(out I, 0);

return state;

}
使用方法:

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