[DUG] Indy

Karl at Work karlreynolds at xtra.co.nz
Fri Aug 4 10:16:57 NZST 2006


> > var Hash    : String;
>
><snip>
>
> >             VStream.Write(Hash, SizeOf(Hash));
>
> I think the preceeding line should read:
>              VStream.Write(Hash, Length(Hash));
>
> As SizeOf will return you 4 bytes being the native size of the string
type,
> ie. a pointer.

He was writing the address of the string to the stream, so SizeOf is correct
for that.  I think you meant to suggest

VStream.Write(Hash[1], Length(Hash));

to write the actual string data to the file, rather than its address.

Also, if you're writing strings to streams, you usually need to delimit them
to separate them from other data; ie. write #0 or #10 (or #13#10) after the
string, depending on the circumstances.  But it sounds like the problem has
been solved anyway.

Cheers,
Carl



More information about the Delphi mailing list