void __fastcall TForm1::FormCreate(TObject *Sender)
{
TIniFile *pIniFile = new TIniFile("c://MyApp//bin//MyApp.ini");
if (pIniFile->ReadBool("AutoLoad", "FormProperties", false) == true)
{
Visible = pIniFile->ReadBool("FormOptions", "Visible", true);
Color = (Graphics::TColor)pIniFile->ReadInteger("FormOptions", "Color", clWindow);
Caption = pIniFile->ReadString("FormOptions", "Caption", "Main");
}
delete pIniFile;
}
1 #include <IniFiles.hpp>
2 路径不必一定是绝对路径,但一般都把ini文件和可执行文件放一起,定位时方便.
3 ReadString 是读,从ini文件中的一段内读取指定Key的值
Retrieves a string value from an INI file.
virtual AnsiString __fastcall ReadString(const AnsiString Section, const AnsiString Ident, const AnsiString Default);
Description
Call ReadString to read a string value from an INI file. Section identifies the section in the file that contains the desired key. Ident is the name of the key from which to retrieve the value. Default is the string value to return if the:
Section does not exist.
Key does not exist.
Data value for the key is not assigned.
1760

被折叠的 条评论
为什么被折叠?



