I use Delphi along with WinHTTP to execute an HTTP request to download some files from the Internet, and I can fulfill the request, but I don’t know how to get IStream from OleVariant, which is returned from ResponseStream, I spent a lot of time searching the Internet, but I can’t figure out how to do this. Here is what I 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'
FreeAndNil(req);
Application.Terminate;
end;
instream := req.ResponseStream as IStream;
ShowMessage('success');
FreeAndNil(instream);
FreeAndNil(req);
end;
But I get an error [DCC Error] main.pas(45): E2015 Operator not applicable to this operand type(line 45 - instream := req.ResponseStream as IStream;).
How to scare IStream from OleVariant?
source
share