M
Miros
Unregistered / Unconfirmed
GUEST, unregistred user!
unit unit1;
.............
.............
.............
TA = packed record
A, B: Word;
end;
TAArr = array of TA;
pTAArr = ^TAArr;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
I : Integer;
ATAArr;
FS: TStream;
begin
New(A);
SetLength(A^, 10);
for I := 0 to 9 do
begin A^.a := I;
A^.b := I * 2;
end;
FS := TFileStream.Create('D:/1.1',fmCreate);
FS.WriteBuffer(A^, Sizeof(TA) * 10);
FreeANdNil(FS);
DisPose(A);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
I : Integer;
ATAArr;
FS: TStream;
begin
New(A);
SetLength(A^, 10);
FS := TFileStream.Create('D:/1.1',fmShareDenyNone);
FS.Position := 0;
FS.ReadBuffer(A^, Sizeof(TA) * 10);
for I := 0 to 9 do
begin
StringGrid1.Cells[I,0] := IntToStr(A^.a);
StringGrid1.Cells[I,1] := IntToStr(A^.b);
end;
FreeANdNil(FS);
DisPose(A);
end;
读出来的和实际结果不对 写入的也不对 这个问题怎么解决!!
.............
.............
.............
TA = packed record
A, B: Word;
end;
TAArr = array of TA;
pTAArr = ^TAArr;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
I : Integer;
ATAArr;
FS: TStream;
begin
New(A);
SetLength(A^, 10);
for I := 0 to 9 do
begin A^.a := I;
A^.b := I * 2;
end;
FS := TFileStream.Create('D:/1.1',fmCreate);
FS.WriteBuffer(A^, Sizeof(TA) * 10);
FreeANdNil(FS);
DisPose(A);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
I : Integer;
ATAArr;
FS: TStream;
begin
New(A);
SetLength(A^, 10);
FS := TFileStream.Create('D:/1.1',fmShareDenyNone);
FS.Position := 0;
FS.ReadBuffer(A^, Sizeof(TA) * 10);
for I := 0 to 9 do
begin
StringGrid1.Cells[I,0] := IntToStr(A^.a);
StringGrid1.Cells[I,1] := IntToStr(A^.b);
end;
FreeANdNil(FS);
DisPose(A);
end;
读出来的和实际结果不对 写入的也不对 这个问题怎么解决!!