Ver Mensaje Individual
  #2  
Antiguo 18-10-2012
Avatar de ZayDun
ZayDun ZayDun is offline
Miembro
 
Registrado: mar 2007
Posts: 129
Reputación: 18
ZayDun Va por buen camino
Puedes verificar si hay conexión antes de realizar la descarga con este ejemplo de escafandra que vi por el foro.

Código Delphi [-]
function Ping(Addr: PCHAR; Rep: integer = 3): boolean;
var
  WSA: TWSAData;
  hIcmpFile: Cardinal;
  Reply: ICMP_ECHO_REPLY;
  He: Phostent;
  n: Integer;
begin
  Result:= false;
  if WSAStartup(MAKEWORD(1, 1), WSA) <> 0 then exit;
  He:= gethostbyname(Addr);
  if He = nil then exit;
  hIcmpFile:= IcmpCreateFile;
  n:= 0;
  repeat
    Result:= IcmpSendEcho(hIcmpFile, PULONG(He.h_addr_list^)^, 0, 0, 0, 
                          PCHAR(@Reply), sizeof(ICMP_ECHO_REPLY), 1000) <> 0;
    if Result then
       Result:= Reply.Status = 0;
    inc(n);
  until Result or (n=3);
  IcmpCloseHandle(hIcmpFile);
  WSACleanup;
end;


La llamada la puedes hacer de esta manera.

Código Delphi [-]
if Ping('www.google.com') then
GetInetFile( internetFile, localFilename)
else
...
Responder Con Cita