Ver Mensaje Individual
  #5  
Antiguo 11-10-2004
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Reputación: 10
marcoszorrilla Va por buen camino
He hecho un par de cambios en el link que publica Julián y me funciona correctamente:
Código Delphi [-]
  unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls,Wininet;
  
    function LeerUnTrozoDeDocumentoHtmDesdeInternet( sUrl: string): string;
  type
    TForm1 = class(TForm)
      Button1: TButton;
      Memo1: TMemo;
      procedure Button1Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.DFM}
  
  function LeerUnTrozoDeDocumentoHtmDesdeInternet( sUrl: string): string;
  type
    tbuffer    = array[0..100] of char;  // Aqui es donde
  puedes poner mas grande el buffer
    pbuffer    = ^TBuffer;
  var
    buffer     : pBuffer;
    a          : cardinal;
    ihConnect,
    ihSession,
    iDocument  : HINTERNET;
  begin
    Result:='NadaDeNada';  // Observa que Length(Result)=10
    ihConnect:=InternetOpen('dChat/2.0 (JulianWEB)',  LOCAL_INTERNET_ACCESS, '', '', 0);
    iDocument:=InternetOpenURL(ihConnect, pChar(sUrl), NIL, 1,
  INTERNET_FLAG_RELOAD or INTERNET_FLAG_DONT_CACHE or INTERNET_FLAG_RAW_DATA, 0);
    if iDocument<>nil then try
      New(buffer);
      InternetReadFile(iDocument, Buffer, sizeof(TBuffer), a);
      Result:=pchar(buffer);
    finally
      internetCloseHandle(iDocument);
      Dispose(buffer);
      InternetCloseHandle(ihConnect);
    end;
  end;
  procedure TForm1.Button1Click(Sender: TObject);
  begin
  Memo1.text:=LeerUnTrozoDeDocumentoHtmDesdeInternet('http://www.clubdelphi.com');
  end;
  
  end.

Un Saludo.
__________________
Guía de Estilo de los Foros
Cita:
- Ça c'est la caisse. Le mouton que tu veux est dedans.
Responder Con Cita