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

来源:互联网 发布:unity3d 对话框 编辑:程序博客网 时间:2024/06/01 22:58
 

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();

原创粉丝点击