Einzelnen Beitrag anzeigen

Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#2

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 15. Jun 2005, 16:11
Hello,

I did some more investigation and I see that working with the Indy 10 components is indeed quite difficult and misty to understand. The component builders wanted to "abstract" the Indy system further, but now it's so abstract that many users have only problems to use the source. On the web you'll see a lot of people telling that they deinstall the Indy 10 and go back to Indy 9. Although the Indy 10 is out now for some time, you'll find not a lot of examples on the web. especially not for Delphi. Very sad for these great components.

If anyone know how to use the Indy 10 idHTTP component in Runtime. (with IOhandlers and Intercepts...) please help us out...

So, I also used another simple way to get a page from the web, using the WinInet API. This API can work with HTTP and FTP. The interface is very C-like, but it's small and it does what I want, just get me the Webpage. (you also don't have to loop to wait for the webpage to finish...) Here is some source I found on the Web:

Delphi-Quellcode:

Uses WinInet;

procedure GetWebPage;
var
  databuffer : array[0..4095] of char;
  ResStr : string;
  hSession, hfile, hRequest: hInternet;
  dwindex,dwcodelen,datalen,dwread,dwNumber: cardinal;
  dwcode : array[1..20] of char;
  Str : pchar;
  AUrl : String;
begin
  FStringList:=TStringList.Create;

  ResStr:='';
  AUrl:='www.google.com';
  hSession:=InternetOpen('InetURL:/1.0',
                         INTERNET_OPEN_TYPE_PRECONFIG,
                         nil,
                         nil,
                         0);
  if assigned(hsession) then
  begin
    hfile:=InternetOpenUrl(
           hsession,
           pchar(AUrl),
           nil,
           0,
           INTERNET_FLAG_RELOAD,
           0);
    dwIndex := 0;
    dwCodeLen := 10;
    HttpQueryInfo(hfile,
                  HTTP_QUERY_STATUS_CODE,
                  @dwcode,
                  dwcodeLen,
                  dwIndex);
    dwNumber := sizeof(databuffer)-1;
    while (InternetReadfile(hfile,
                            @databuffer,
                            dwNumber,
                            DwRead)) do
    begin
      if dwRead =0 then break;
      databuffer[dwread]:=#0;
      Str := pchar(@databuffer);
      resStr := resStr + Str;
    end;
    if assigned(hfile) then InternetCloseHandle(hfile);
  end;
  InternetCloseHandle(hsession);

  FStringList.text := resStr;
Rob
  Mit Zitat antworten Zitat