Uses inifiles;<br><br><br>例1、<br> Ini := TIniFile.Create(ParamStr(1));<br> try<br> OutputFileName := Ini.ReadString('System','Output File',''); {do not localize}<br> finally<br> Ini.Free;<br> end;<br><br><br><br><br><br>例2、<br> FIniFile := TIniFile.Create(IniFileName);<br> if ContentFile = '' then<br> ContentFile := FIniFile.ReadString('System', 'Content File', 'ContentFile');<br> if OutputFile = '' then<br> OutputFile := FIniFile.ReadString('System', 'Output File', 'OutputFile.html');<br> FIniFile.Free;<br><br><br>例3:<br> RSCON: TIniFile;<br>begin<br> { the ReportSmith CON file is actually an INI file -- assumes in win dir}<br> RSCon := TIniFile.Create(TiniFilename);<br> TempStr := RSCon.ReadString(ConnectNamesSection, ConnectNamesKey, '');<br> { CON file contents differs for SQL connections }<br> if MastData.Database.IsSQLBased then<br> begin<br> if AnsiPos(SQLConTitle,TempStr) = 0 then<br> begin<br> if TempStr <> '' then<br> TempStr := TempStr + ',';<br> RSCon.WriteString(ConnectNamesSection, ConnectNamesKey, TempStr+SQLConTitle);<br> end;<br> RSCon.WriteInteger(MASTSQLSection, TypeKey, SQLTypeVal);<br> RSCon.WriteString(MASTSQLSection, SQLDataFilePathKey, DBpath);<br> RSCon.WriteString(MASTSQLSection, ServerKey, SQLServerVal);<br> RSCon.WriteString(MASTSQLSection, SQLUseridKey, SQLUseridVal);<br> end<br> else<br> begin<br> if AnsiPos(AppConTitle,TempStr) = 0 then<br> begin<br> if TempStr <> '' then<br> TempStr := TempStr + ',';<br> RSCon.WriteString(ConnectNamesSection, ConnectNamesKey, TempStr+AppConTitle);<br> end;<br> RSCon.WriteInteger(MASTAPPSection, TypeKey, TypeVal);<br> RSCon.WriteString(MASTAPPSection, DataFilePathKey, DBpath);<br> RSCon.WriteString(MASTAPPSection, ServerKey, ServerVal);<br> end;<br> RSCon.Free;<br>