Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.04.22;
Скачать: CL | DM;

Вниз

Чтение записей из файла   Найти похожие ветки 

 
Lame1   (2002-04-10 12:24) [0]

В общем никогда с такой проблемой не встречался, а тут вот понадобилось:

type TTestRec = record
StrLength: integer;
Path: string;
StrLength2: integer;
Path2: string;
end;

const filename= "C:\tst.txt";

procedure TForm1.Button1Click(Sender: TObject);
var f: TFileStream;
rec: TTestRec;
tmp: integer;
begin
f:= TFileStream.Create(filename, fmCreate);
try
rec.Path:= "line1";
rec.StrLength:= length(rec.Path);
rec.Path2:= "line2";
rec.StrLength2:= length(rec.Path2);
tmp:=sizeof(rec)+ length(rec.Path)+ length(rec.Path2);
f.WriteBuffer(rec, tmp);
finally f.Free end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var f: TFileStream;
rec: TTestRec;
begin
f:= TFileStream.Create(filename, fmOpenRead);
try
f.ReadBuffer(rec.StrLength, sizeof(rec.StrLength));
f.ReadBuffer(rec.path, rec.StrLength);
f.ReadBuffer(rec.StrLength2, sizeof(rec.StrLength2));
f.ReadBuffer(rec.path2, rec.StrLength2);
finally f.Free end;
end;


Строка выделенная жирным явно читает не те байты которые должна.....Помогите плз.



Страницы: 1 вся ветка

Текущий архив: 2002.04.22;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.024 c
1-69929
Veselov
2002-04-09 21:33
2002.04.22
Adobe Acrobat или как открыть с его поиощью файл...


6-69945
otari
2002-02-09 22:48
2002.04.22
Это очен интересно !!!


14-69971
Merlin
2002-03-13 18:49
2002.04.22
СПАМ на delphi@mastak.com


14-70012
AndreyK
2002-03-13 11:19
2002.04.22
Помогите


1-69926
DMA
2002-04-09 20:06
2002.04.22
Как определить какое окно сейчас активное?