判断本地的电脑是否与Internet网络连接

来源:互联网 发布:青岛新房每日成交数据 编辑:程序博客网 时间:2024/04/29 12:50

using System;
using System.Runtime.InteropServices;

namespace MyAssist
{
/// <summary>
/// netstat 的摘要说明。
/// </summary>
public class netstat
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
public bool IsConnected()
{
int I=0;
bool state = InternetGetConnectedState(out I,0);
return state;
}
}
}