//判断是否是否连接了网络
public enum ConnectedStates
{
INTERNET_CONNECTION_MODEM = 1,
INTERNET_CONNECTION_LAN = 2,
INTERNET_CONNECTION_PROXY = 4,
INTERNET_CONNECTION_MODEM_BUSY = 8,
INTERNET_RAS_INSTALLED = 16,
INTERNET_CONNECTION_OFFLINE = 32,
INTERNET_CONNECTION_CONFIGURED = 64,
}
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int desc,int reserved);
public bool isConnectInternet()
{
Boolean bOnLine = true;
int desc = 0;
bOnLine = InternetGetConnectedState(out desc, 0);
if(bOnLine)
{
return true;
}
else
{
return false;
}
}