Вниз
Скачать: CL | DM;

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

 
Lame1   (2002-04-10 13:21) [12]

Просто хотел спросить: этот код работает потому-что он правильный или потому-что я неправильный?

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

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

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

procedure TForm1.btnReadClick(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.Path, rec.StrLength2);
finally f.Free end;
end;



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

Скачать: CL | DM;



Память: 0.44 MB
Время: 0.016 c
3-69718
Nickolaus
2002-03-29 22:41
2002.04.22
Как


7-70044
Delphimun
2002-01-27 15:54
2002.04.22
Существует ли в Способ запустить пргу ещё до загрузки windows(в dos)


1-69807
NiaSoft
2002-04-08 22:49
2002.04.22
Как получить снимок с экрана, включая режим Direct и т.п.


3-69684
Grafichsoft
2002-03-29 14:29
2002.04.22
Как получить доступ к базам .tps программы отчетсности в ПФР?


4-70060
Velocity
2002-02-18 10:12
2002.04.22
ListBox на WinAPI




   Наверх