uses IniFiles;
{写入列表框中的项目到ini中}
//调用 WriteListBoxItems('settings.ini','Listbox',ListBox1);
procedure WriteListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
var
INI: TINIFile;
iniPath:string;//ini路径
I: Integer;
begin;
iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
INI := TINIFile.Create(iniPath);
try
INI.EraseSection(ASection);
INI.WriteInteger(ASection, 'Count', ListBox.Items.Count);
for I := 0 to ListBox.Items.Count - 1 do
begin
INI.WriteString(ASection, 'Item' + IntToStr(I), ListBox.Items[I]);
end;
finally
INI.Free;
end;
end;
{读取ini中的信息到列表框中中}
//调用 ReadListBoxItems('settings.ini','Listbox',ListBox1);
procedure ReadListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
var
INI: TINIFile;
iniPath:string;
I,count: Integer;
begin
iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
INI := TINIFile.Create(iniPath);
try
ListBox.Clear;
Count := INI.ReadInteger(ASection, 'Count', 0);
for I := 0 to Count - 1 do
begin
ListBox.Items.Add(INI.ReadString(ASection, 'Item' + IntToStr(I), '0'));
end;
finally
INI.Free;
end;
end;
//调用 WriteListBoxItems('settings.ini','Listbox',ListBox1);
procedure WriteListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
var
INI: TINIFile;
iniPath:string;//ini路径
I: Integer;
begin;
iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
INI := TINIFile.Create(iniPath);
try
INI.EraseSection(ASection);
INI.WriteInteger(ASection, 'Count', ListBox.Items.Count);
for I := 0 to ListBox.Items.Count - 1 do
begin
INI.WriteString(ASection, 'Item' + IntToStr(I), ListBox.Items[I]);
end;
finally
INI.Free;
end;
end;
{读取ini中的信息到列表框中中}
//调用 ReadListBoxItems('settings.ini','Listbox',ListBox1);
procedure ReadListBoxItems(const AINIFile, ASection: string; ListBox: TListBox);
var
INI: TINIFile;
iniPath:string;
I,count: Integer;
begin
iniPath:=ExtractFilePath(Application.ExeName)+AINIFile;
INI := TINIFile.Create(iniPath);
try
ListBox.Clear;
Count := INI.ReadInteger(ASection, 'Count', 0);
for I := 0 to Count - 1 do
begin
ListBox.Items.Add(INI.ReadString(ASection, 'Item' + IntToStr(I), '0'));
end;
finally
INI.Free;
end;
end;