DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Detect a RAS connection to the internet

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.

const
   INTERNET_CONNECTION_MODEM           = 1;
   INTERNET_CONNECTION_LAN             = 2;
   INTERNET_CONNECTION_PROXY           = 4;
   INTERNET_CONNECTION_MODEM_BUSY      = 8;
 
 function InternetGetConnectedState(lpdwFlags: LPDWORD;
   dwReserved: DWORD): BOOL; stdcall; external 'WININET.DLL';
 
 function  _IsConnectedToInternet: Boolean;
 var
   dwConnectionTypes: Integer;
 begin
   try
     dwConnectionTypes := INTERNET_CONNECTION_MODEM +
                          INTERNET_CONNECTION_LAN +
                          INTERNET_CONNECTION_PROXY;
     if InternetGetConnectedState(@dwConnectionTypes, 0) then
       Result := true
     else
       Result := false;
   except
     Result := false;
   end;
 end;
 

Generated 8:01:59 on Oct 17, 2019