Ver Mensaje Individual
  #1  
Antiguo 29-06-2006
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Cómo saber si estoy conectado a Internet

Puedes usar el componente TCP para recoger la dirección local IP. Si esta es "0.0.0.0." entonces no estás conectado.

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  if TCP1.LocalIp = '0.0.0.0' then
    ShowMessage('No estoy conectado');
end;

El siguiente texto y código es aportación de: Rigg

Si lo que quieres hacer es detectar si se está conectado o no a Internet
debes importar la función InetIsOffLine de la librería URL.DLL y luego
simplemente llamarla. El código debiera quedar mas o menos así:

Código Delphi [-]
function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL';
.
.
.
if InetIsOffline(0) then
    ShowMessage('No conectado a internet')
else
    ShowMessage(Connectado a Internet');


Notas:

- La funcion retorna TRUE si existe conexión.
- La variable Flag es ignorada.
- Si quieres mas información revisa el siguiente sitio:

http://msdn.microsoft.com/library/psdk/shellcc/shell/Functions/InetIsOffline.htm
Responder Con Cita