Question

I am using Delphi along with WinHTTP to do an HTTP request to download some files from the internet, and I can do the request but I don't know how to get the IStream from the OleVariant that is returned from ResponseStream. I have spent a lot of time googling but I can't figure out how to do it. Here is what I have tried:

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;

But I get the error [DCC Error] main.pas(45): E2015 Operator not applicable to this operand type (line 45 is instream := req.ResponseStream as IStream;).

How do I scare the IStream out of an OleVariant?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top