type
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
ListBox2: TListBox;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
ini : TIniFile;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a:integer;
Temp : TStringList;
begin
Temp := TStringList.Create;
ListBox2.Clear;
ListBox2.Visible := falsE;
ListBox1.Clear;
ini.ReadSections(ListBox1.Items);
for a:=0
to ListBox1.Count-1
do
begin
Temp.Clear;
ini.ReadSectionValues( ListBox1.Items.Strings[a],Temp);
ListBox2.Items.Add('
SECTION - '+ListBox1.Items.Strings[a]);
ListBox2.Items.AddStrings(temp);
end;
Temp.Free;
ListBox2.Visible := true;
Caption := '
Lines: '+inttostr(ListBox2.Count+ListBox1.Count);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ini := TIniFile.Create('
c:\my.ini');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ini.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var selected_ : integer;
begin
selected_ := SendMessage(ListBox1.Handle,LB_GETCURSEL,0,0);
ini.EraseSection(ListBox1.Items.Strings[selected_]);
ini.UpdateFile();
// only win9x
ListBox1.Items.Delete(selected_);
end;