Given stream savetofile VariantToStream and StreamToVariantprocedure VariantToStream (const V: OLEVariant; Stream: TStream); var P: Pointer; begin Stream.Position: = 0; Stream.Size: = VarArrayHighBound (V, 1) - VarArrayLowBound (V, 1 ) 1; p: = varitelock (v); stream.write (p ^, stream.size); varArrayunlock (v); stream.position: = 0;
Procedure streamtovariant (stream: tstream; var v: pointer; begin v: = varArraycreate ([0, stream.size - 1], varbyte); p: = varArrayLock (v); stream.position: = 0; stream.read (p ^, stream.size); varArrayunlock (v); end;