Obtener un IStream de un OleVariant
Estoy usando Delphi junto con WinHTTP para hacer una solicitud HTTP para descargar algunos archivos de Internet, y puedo hacer la solicitud, pero no sé cómo obtener el IStream del OleVariant que se devuelve desdeResponseStream
. He pasado mucho tiempo buscando en Google, pero no puedo entender cómo hacerlo. Esto es lo que he intentado:
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;
Pero me sale el error[DCC Error] main.pas(45): E2015 Operator not applicable to this operand type
(la línea 45 esinstream := req.ResponseStream as IStream;
)
¿Cómo asusto el IStream de un OleVariant?