I have an INI file which a session has multiple properties:
[DLLS]
Dll1=...
Dll2=...
Dll3=...
In the example above there are 3 properties.
Is there a method in Delphi to identify how many properties the [DLLS]
session has?
I have an INI file which a session has multiple properties:
[DLLS]
Dll1=...
Dll2=...
Dll3=...
In the example above there are 3 properties.
Is there a method in Delphi to identify how many properties the [DLLS]
session has?
procedure TForm1.Button1Click(Sender: TObject);
var
MeuINI : TIniFile;
strValores : TStringList;
begin
MeuINI := TIniFile.Create('Z:\Temp\Teste.ini');
MeuINI.UpdateFile;
strValores := TStringList.Create;
if MeuINI.SectionExists('DLLS') then
MeuINI.ReadSection('DLLS',strValores);
ShowMessage(IntToStr(strValores.Count));
ShowMessage(strValores.Text);
end;
Example of the click of a button that does what you want:
It can be done as follows, create a new project enter a TButton
and a TMemo
and in the event onclick
of the button paste the following code:
procedure TForm1.Btn1Click(Sender: TObject);
var VCount: TStringList;
INI: TiniFile;
begin
VCount := TStringList.Create;
INI := TIniFile.Create('c:\test.ini');
if INI.SectionExists('DLLS') then INI.ReadSection('DLLS', VCount);
INI.Free;
memo1.Lines.Add(IntToStr(VCount.Count));
end;
Any question please.