http://www.delphibbs.com/delphibbs/dispq.asp?lid=1103320
另:stream to variant;
function StreamToVariant(Stream: TStream): OleVariant;
var
p: Pointer;
begin
Result := VarArrayCreate([0, Stream.Size - 1], varByte);
p := VarArrayLock(Result);
try
Stream.Position := 0;
Stream.Read(p^, Stream.Size);
finally
VarArrayUnlock(Result);
end;
end;
function VariantToStream(const Data: OleVariant ):TStream;
var
p: Pointer;
Stream: TStream;
begin
p := VarArrayLock(Data);
try
Stream.Write(p^, VarArrayHighBound(Data,1) + 1);
finally
VarArrayUnlock(Data);
end;
Result:=Stream;
end;