Пример
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
procedure SaveStringToStream(aStr: string; aStream: TStream); var l: integer; begin l := length(aStr); aStream.WriteBuffer(l, SizeOf(l)); if l > 0 then aStream.WriteBuffer(PChar(aStr)^, l); end; function LoadStringFromStream(aStream: TStream): string; var l: integer; begin aStream.ReadBuffer(l, SizeOf(l)); if l > 0 then begin SetLength(Result, l); aStream.ReadBuffer(PChar(Result)^, l) end else Result := ''; end; |