Header file wininet. h
Static library wininet. Lib
Bool internetgetconnectedstate (
Out lpdword lpdwflags,
In DWORD dwreserved
);
DWORD flags; // Internet Access Method
Bool m_bonline; // online or not
M_bonline = internetgetconnectedstate (& flags, 0 );
If (m_bonline) // online
{
Switch (& flags)
{
Case internet_connection_modem:
Afxmessagebox ("online: dial-up Internet ");
Break;
Case internet_connection_lan:
Afxmessagebox ("online: via LAN ");
Break;
Case internet_connection_proxy:
Afxmessagebox ("online: proxy ");
Break;
}
If (& flags = internet_connection_modem_busy)
Afxmessagebox ("modem is occupied by other non-Internet connections ");
}
Else
Afxmessagebox ("not online ");
In addition, there are more explanations on msdn:
Parameters
Lpdwflags
Address of an unsigned long integer variable where the connection description shocould be returned. This can be a combination of the following values:
Internet_connection_configured
Local system has a valid connection to the Internet, but it may or may not be currently connected.
Internet_connection_lan
Local system uses a local area network to connect to the Internet.
Internet_connection_modem
Local system uses a modem to connect to the Internet.
Internet_connection_modem_busy
No longer used.
Internet_connection_offline
Local System is in offline mode.
Internet_connection_proxy
Local system uses a proxy server to connect to the Internet.
Internet_ras_installed
Local System has Ras installed.
Dwreserved
Reserved. must be set to zero.
Return Value
Returns true if there is an Internet connection, or false otherwise.
Function Information
Windows NT use version 4.0. implemented only as an ANSI function.
Windows use Windows 95 and later. implemented only as an ANSI function.
Header wininet. h
Import library wininet. Lib
Minimum availability Internet Explorer 4.0
The returned value contains internet_connection_offline to determine whether it is offline.