Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #20  
Antiguo 27-09-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 26
seoane Va por buen camino
Vamos a ver, el problema es que la pagina suelta un #0 en medio del texto, sin venir a cuento (al menos yo no veo porque lo hace). El carácter #0 (o carácter nulo) se utiliza para indicar el final de una cadena de texto, en delphi, en C y en muchos otros lenguajes. Cuando tu le pasas ese texto a un memo windows interpreta el #0 como el final del texto, por eso no muestra el resto de la cadena.

Una solución rápida es sustituir el carácter #0 por, por ejemplo, un espacio:
Código Delphi [-]
uses WinInet;

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;

// Por ejemplo
var
  Stream: TStringStream;
begin
  Stream:= TStringStream.Create('');
  try
    DownloadToStream('http://casacimar.com.bo/tarea.html',Stream);
    Memo1.Lines.Text:= Stream.DataString;
  finally
    Stream.Free;
  end;
end;
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
StringList: Modificar un item en particular NEG1414 C++ Builder 3 25-08-2007 20:26:50
Problema con StringList MaMu Varios 2 26-05-2007 21:40:45
Llenar datos en StringList Caro OOP 2 12-11-2005 17:20:57
Recorrer un StringList bustio Varios 2 27-02-2005 19:50:21
Limite del StringList victork_py Varios 8 11-05-2004 22:19:11


La franja horaria es GMT +2. Ahora son las 02:58:29.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi