C#检测本地网络状态

using System;
using System.Runtime.InteropServices; public static class NetTool
{
[Flags]
private enum ConnectionState
{
INTERNET_CONNECTION_MODEM = 0x1,
INTERNET_CONNECTION_LAN = 0x2,
INTERNET_CONNECTION_PROXY = 0x4,
INTERNET_RAS_INSTALLED = 0x10,
INTERNET_CONNECTION_OFFLINE = 0x20,
INTERNET_CONNECTION_CONFIGURED = 0x40
} [DllImport("wininet.dll", CharSet = CharSet.Auto)]
static extern bool InternetGetConnectedState(ref ConnectionState lpdwFlags, int dwReserved); public static bool IsConnectedToInternet()
{
ConnectionState description = ;
bool conn = InternetGetConnectedState(ref description, );
return conn;
}
}
上一篇:微信小程序(有始有终,全部代码)开发--- 新增【录音】以及UI改进


下一篇:通过更改页表权限增加系统调用