Something Strange
enum InternetConnectionState: int
{
INTERNET_CONNECTION_MODEM = 0x1,
INTERNET_CONNECTION_LAN = 0x2,
INTERNET_CONNECTION_PROXY = 0x4,
INTERNET_RAS_INSTALLED = 0x10,
INTERNET_CONNECTION_OFFLINE = 0x20,
INTERNET_CONNECTION_CONFIGURED = 0x40
}
// import WIN API functions
[DllImport("wininet.dll", CharSet=CharSet.Auto)]
static extern bool InternetGetConnectedState(
ref InternetConnectionState lpdwFlags,
int dwReserved);
/// </summary>
/// <returns></returns>
public static bool IsConnected( )
{
bool bConnected=false;
InternetConnectionState flags = 0; bConnected=InternetGetConnectedState(ref flags,0) ;
return bConnected;
}
I am checking using the InternetGetConnectedState WIN API function whether the local machine is connected to internet or not. It works well, but not in this special case. If I connect to internet and disconnect it manually, then the IsConnected method return still true value. What is wrong with the code?
Thank you