stream --> variant
var
stm: TMemoryStream;
v: Variant;
p: PChar;
begin
....
v := VarArrayCreate([0, stm.size-1], varByte);
p := VarArrayLock(v);
stm.readbuffer(p^, stm.size);
VarArrayUnlock(v);
...
end;
variant --> stream
...
b := VarArrayLowBound(v);
e := VarArrayHighBound(v);
p := VarArrayLock(v);
Stm.Writebuffer(p^, e - b + 1);
VarArrayUnlock(v);
stm.seek(0,0);
...