Domanda

Sto usando Delphi insieme a WinHttp per fare una richiesta HTTP per scaricare alcuni file da Internet e posso fare la richiesta ma non so come ottenere l'istream da Olevariant da cui viene restituito ResponseStream. Ho trascorso molto tempo a cercare su Google, ma non riesco a capire come farlo. Ecco cosa ho provato:

var
  req: IWinHTTPRequest;
  instream: IStream;
begin
  req := CoWinHTTPRequest.Create;

  req.Open('GET', 'http://google.com', false);
  req.Send('');

  if req.Status <> 200 then
  begin
    ShowMessage('failure'#10 + req.StatusText);

    FreeAndNil(req);

    Application.Terminate;
  end;

  instream := req.ResponseStream as IStream;

  ShowMessage('success');

  FreeAndNil(instream);
  FreeAndNil(req);

end;

Ma ricevo l'errore [DCC Error] main.pas(45): E2015 Operator not applicable to this operand type (La riga 45 è instream := req.ResponseStream as IStream;).

Come faccio a spaventare l'Istream da un olevariante?

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top