Check if PC is connected to the Internet

Download source code

uses
  clWinInet, clDownloader, clResourceState;
 
//checks the Internet connected state and tries to access the specified web resource
//by using of the system connection settings: proxy, socks, etc.
function CheckInternetConnection(const AUrl: string): Boolean;
var
  details: Cardinal;
  http: TclDownloader;
begin
  Result := InternetGetConnectedState(@details, 0);
  if not Result then Exit;
 
  http := nil;
  try
    http := TclDownloader.Create(nil);
 
    http.URL := AUrl;
    http.LocalFile := '';
    http.TryCount := 1;
 
    http.Start(False);
 
    Result := (http.ResourceState.LastStatus in [psSuccess, psErrors]);
  finally
    http.Free();
  end;
end;

Add Feedback