![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
Código:
function DownloadToStream(Url: string; Stream: TStream): Boolean;
var
hNet: HINTERNET;
hUrl: HINTERNET;
Buffer: PChar;
BytesRead: DWORD;
i: Integer;
begin
Result := FALSE;
hNet := InternetOpen('agent', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if (hNet <> nil) then
begin
hUrl := InternetOpenUrl(hNet, PChar(Url), nil, 0,
INTERNET_FLAG_RELOAD, 0);
if (hUrl <> nil) then
begin
GetMem(Buffer,100*1024);
try
while (InternetReadFile(hUrl, Buffer, 100*1024, BytesRead)) do
begin
if (BytesRead = 0) then
begin
Result := TRUE;
break;
end;
// Aqui sustituimos el caracter nulo por un espacio
for i:= 0 to BytesRead - 1 do
if Buffer[i] = #0 then
Buffer[i]:= #32;
Stream.WriteBuffer(Buffer^,BytesRead);
end;
finally
FreeMem(Buffer);
end;
InternetCloseHandle(hUrl);
end;
InternetCloseHandle(hNet);
end;
end;
try
DownloadToStream(url,Stream);
Memo1.Lines.Text:= Stream.DataString;
finally
Stream.Free;
end;
Gracias |
|
#2
|
||||
|
||||
|
¿Y cuando tarda más de 30 segundos en qué punto de ese procedimiento se queda parado?
¿los has ejecutado paso a paso?
__________________
Germán Estévez => Web/Blog Guía de estilo, Guía alternativa Utiliza TAG's en tus mensajes. Contactar con el Clubdelphi ![]() P.D: Más tiempo dedicado a la pregunta=Mejores respuestas. |
|
#3
|
|||
|
|||
|
lo he solucionado con un
try ... except .. finally de esta forma si no conecta con la web por el motivo que sea me lleva a otras sentencias donde puedo indicarle que vuelva a intentarlo pasados 30 minutos. gracias!! |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| falla conexion mysql | jaimeh | MySQL | 3 | 06-05-2010 13:34:24 |
| conexion de internet falla en la red | m8estrella83 | Redes | 3 | 11-02-2010 20:47:37 |
| Cuando falla la conexión | JLR | Conexión con bases de datos | 8 | 31-10-2007 12:56:32 |
| Conexion a firebird Falla | Paoti | Conexión con bases de datos | 7 | 11-05-2004 21:35:33 |
|