Ich habe mir dazu mal einen Streamhelper geschrieben, funktioniert bislang problemlos...
Delphi-Quellcode:
[...}
type
TStreamHelper = class helper for TStream
public
procedure ReadString(var Target : string);
procedure WriteString (const s: string);
end;
[...]
procedure TStreamHelper.ReadString(var Target: String);
var
len : Integer;
begin
ReadBuffer(len, SizeOf(len));
SetLength(Target, len);
if (len > 0) then
ReadBuffer(Target[1], len * SizeOf(Char));
end;
procedure TStreamHelper.WriteString (const s: string);
var
len : Integer;
begin
len := Length(s);
WriteBuffer(len, SizeOf(len));
if (len > 0) then
WriteBuffer(s[1], len * SizeOf(Char));
end;