先将 string转换成流TStringStream
procedure StreamToVariant(var Data: OleVariant; Stream: TStringStream);
var
p: Pointer;
begin
Data := VarArrayCreate([0, Stream.Size - 1], varByte);
p := VarArrayLock(Data);
try
Stream.Position := 0;
Stream.Read(p^, Stream.Size);
finally
VarArrayUnlock(Data);
end;
end;