Autor Beitrag
CopEater
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Do 17.04.03 20:42 
wie bekomme ich die anzahl der schlüssel einer sektion einer ini-datei raus?

thx

ce
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Do 17.04.03 21:04 
In dem du alle Sektionen in ein TSringList lädst und dann den Count abliest.

Ich glaube das geht mit ReadSections(Strings: TStrings).

_________________
Popov
CopEater Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Do 17.04.03 21:13 
danke für deine hilfe.
könntest du das mal bitte an einem einfachen beispiel erklären?
ich bin noch anfänger... :oops:

_________________
Greetz
CE
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Fr 18.04.03 10:59 
Hallo,

das wird alles hier beschrieben.

Gruß
Klabautermann
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Fr 18.04.03 14:27 
Damit müßte es gehen (das Einlesen aller Sektionen):

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure ReadIniSections(IniFile: String; Strings: TStrings);
begin
  with TIniFile.Create(IniFile) do try
    ReadSections(Strings);
  finally Free end;
end;


IniFile ist der Pfad zu der Ini Datei.

Strings ist die Liste die zurückgegeben wird.

Aurufen kann man das so:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  sl: TStringList;
  k: Integer;
begin
  sl := TStringList.Create;
  try
    ReadIniSections('c:\abc.ini', sl);
    k := sl.Count; //<<<<<<<<
  finally
    sl.Free;
  end;
end;

_________________
Popov