c#通过winAPI函数InternetGetConnectedState获得本地系统的网络连接状态
///
/// 检测网络状态
///
class NativeMethods
{
//检测网络状态
[DllImport("wininet.dll", EntryPoint = "InternetGetConnectedState")]
public extern static bool InternetGetConnectedState(out int conState, int reder);
public static bool CheckInternet()
{
int Desc = 0;
return InternetGetConnectedState(out Desc, 0);
}
}