如何遍历读取ini文件的所有节点
我现在保存了一个配置文件,
[A]
Left=100;
Height=50;
Width =40;
[B]
Left=30;
Height=40;
Width =20;
现在我如何按照段名,来读取各个段名下面的值,请指教!
[解决办法]
ReadSections()
ReadSectionValues()
ReadSection()
[解决办法]
TStringList *pStringList = new TStringList();
pinifile-> ReadSection( "A ",pStringList);
int nStringListCount = pStringList-> Count;
for(int i=0;i <nStringListCount;i++)
{
String sSection = pStringList-> Strings[i];
Memoport-> Lines-> Add(sSection + "= " + pinifile-> ReadString( "A ",
sSection, " "));
}
[解决办法]
用TStringList;
sl-> LoadFromFile( "a.ini ");
for(long i=0; i <sl-> Count; i++)
{
AnsiString aline = sl-> Strings[i];
....
}
[解决办法]
sl-> LoadFromFile( "a.ini ");
for(long i=0; i <sl-> Count; i++)
{
AnsiString aline = sl-> Strings[i];
AnsiString name = sl-> Names[i];
AnsiString value = sl-> Values[name];
}