Tema: WinSock
Ver Mensaje Individual
  #4  
Antiguo 20-08-2003
hogol hogol is offline
Miembro
 
Registrado: jul 2003
Posts: 62
Reputación: 21
hogol Va por buen camino
Yo utilizo el siguiente código para descargar ficheros de internet.
kurl contiene la dirección url completa del fichero (ej. http://achilipu.com/arriquitaun.jpg) y el fichero se copia en c:\fichero.jpg
Para que funcione debes añadir wininet en la lista de uses.

Espero que te sirva

Saludos
Hogol



procedure TForm1.descarga(kurl:string);
var
hHttpSession, hReqUrl: HInternet;
Buffer: array [0..1023] of Char;
nRead: Cardinal;
nwrite : Integer;
ToF : file;
begin

hHttpSession := InternetOpen ('FindWeb', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
hReqUrl := InternetOpenURL (hHttpSession, PChar(kurl),nil,0,0,0);

AssignFile(ToF, 'c:\fichero.jpg');
Rewrite(ToF, 1);
repeat
InternetReadFile (hReqUrl, @Buffer, sizeof (Buffer), nRead);
BlockWrite(ToF, Buffer, nRead, nWrite);
until nRead = 0;

InternetCloseHandle (hReqUrl);
closefile(ToF);
InternetCloseHandle (hHttpSession);


end;
Responder Con Cita