D
ddzhouqian
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
type
PRecord=^TRecord;
Trecord=record
name:array[0..20] of char;
age:integer;
end;
a1:array[0..10] of Trecord;
FList:TList;
procedure TForm1.Button1Click(Sender: TObject);
begin
Fa1[0].name:='a1';
Fa1[0].age:=10;
Fa1[1].name:='a2';
Fa1[1].age:=11;
FList:=TList.Create;
FList.Add(@Fa1[0]);
FList.Add(@Fa1[1]);
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for i:=0 to FList.Count-1 do
begin
//Dispose(PRecord(FList.Items));//这句加上会报无效的指针的错误
listbox1.Items.Add(PRecord(FList.Items)^.name);
end;
FList.Free;
end;
以上代码为测试代码,问高手:
如何完全释放Flist,添加的静态数组的地址如何释放?是不是不需要释放?
type
PRecord=^TRecord;
Trecord=record
name:array[0..20] of char;
age:integer;
end;
a1:array[0..10] of Trecord;
FList:TList;
procedure TForm1.Button1Click(Sender: TObject);
begin
Fa1[0].name:='a1';
Fa1[0].age:=10;
Fa1[1].name:='a2';
Fa1[1].age:=11;
FList:=TList.Create;
FList.Add(@Fa1[0]);
FList.Add(@Fa1[1]);
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for i:=0 to FList.Count-1 do
begin
//Dispose(PRecord(FList.Items));//这句加上会报无效的指针的错误
listbox1.Items.Add(PRecord(FList.Items)^.name);
end;
FList.Free;
end;
以上代码为测试代码,问高手:
如何完全释放Flist,添加的静态数组的地址如何释放?是不是不需要释放?