Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Testing if you are connected to the internet

Question: How can I tell at runtime if I am connected to the internet? Answer: You can use the TCP component to retrieve the Local IP address. If it is "0.0.0.0" then there is no connection. Example: procedure TForm1.Button1Click(Sender: TObject); begin if TCP1.LocalIp = '0.0.0.0' then ShowMessage('Your not connected!'); end;