Are we On-Line (Views: 101)
Are we On-Line?
The following code is a possibility to detect a connection to the internet,
altough it is not 100%.
I have tested it on Windows NT with LAN connections (DSL and cable)
and it worked in these cases.
function InternetConnected: Boolean;
INTERNET_CONNECTION_MODEM = 1; // local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_LAN = 2; // local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4; // local system uses a proxy server to connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY = 8; // local system's modem is busy with a non-Internet connection.
Result := InternetGetConnectedState(@dwConnectionTypes, 0);
Note: this solution only works if IE is installed, so it would fail on
'older' machines, like most Windows NT 4 computers. You app would then
display an error during program startup if you referred to Wininet.
<< Back to main page