Ver Mensaje Individual
  #2  
Antiguo 16-10-2018
CarlosReyesg CarlosReyesg is offline
Miembro
 
Registrado: ago 2010
Posts: 21
Reputación: 0
CarlosReyesg Va por buen camino
Cita:
Empezado por Missael Ver Mensaje
Buenas Tardes y hola de nuevo

Estoy haciendo una aplicación en delphi donde el usuario debe subir unos archivos a un servidor, un botón los manda al servidor, ahí todo esta bien, mi problema es que no se como hacer que cuando no tenga conexión a Internet, la aplicación verifique su conexión cada cierto tiempo, cuando ya detecte que el host tiene Internet, automáticamente se reanude la acción de mandar los archivos al servidor y así sucesivamente, cuando los haya subido todos, solo mandar un mensaje de 'Upload Succesful'

Espero puedan ayudarme, Muchas Gracias
buen día
te comparto una de las funciones que utilizo para validar si hay conexión a Internet no se si te sirva lo demás que necesitas tenes que analizarlo
funciona solo para windows
Código Delphi [-]
/////////////////////////////////////////////////////
///   Validar si hay internet
///   Ing. Carlos Reyes
class function TClientCommon.Ping(URL: PCHAR): Boolean;
var
  hNet      : Pointer;
  hUrl      : Pointer;
  BytesRead : DWORD;
  Buffer    : array [0..64] of char;
begin
   Result    := False;
   BytesRead := 0;

   if InternetAttemptConnect(0) <> ERROR_SUCCESS then exit;

   hNet := InternetOpen('WebIng', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
   if hNet <> nil then
   begin
      hUrl:= InternetOpenUrl(hNet, URL, nil, 0, INTERNET_FLAG_RELOAD, 0);
      if hUrl <> nil then
      begin
         ZeroMemory(@Buffer[0], sizeof(Buffer));
         Result:= InternetReadFile(hUrl, @Buffer[0], sizeof(Buffer), BytesRead);
         Result:= Result and (BytesRead > 0);
         InternetCloseHandle(hUrl);
      end;
      InternetCloseHandle(hNet);
   end;
   Result := Result and (Pos('Access Denied', Buffer) = 0);
end;

Código Delphi [-]
Implementacion
if TClientCommon.Ping('http://www.google.com') then
begin
     //escribie codigo que necesites
end;
pienso que deberias de crear una apliacion de tipo servicio y coloques un timer que puedas configurarlo atravez de un archivo .ini

ojala te sirva......



"Entre las dificultades se esconde la oportunidad"--> Albert Einstein
Responder Con Cita