Problem with records and TStream.

Hi,

I have created a record somthing like this:
[code]
...
type
TData = Record
Name: WideString;
Age: Byte;
end;
var
Data: TData;
FixupInfo: Integer;
...
[/code]

then I use a TStream to write the info:

[code]
...
Data.Name := 'Arash';
...
Stream.WriteResourceHeader('Data', FixupInfo);
Stream.WriteBuffer(Data, SizeOf(Header));
Stream.FixupResourceHeader(FixupInfo);
Stream.SaveToFile(FileName');
...
[/code]

Later when i try to load the file after a reboot the procedure fails. I use this one:

[code]
...
var
ImageSize: Integer;
begin
with Stream do
begin
ReadResHeader;
Position := Position - 4;
ReadBuffer(ImageSize, SizeOf(Longint));
ReadBuffer(Data, ImageSize);
ShowMessage(Data.Name);
...
[/code]

This doesn't work. Why?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories