BCB读写ini

#include <inifiles.hpp>

__fastcall TForm1::TForm1(TComponent *Owner) : TForm(Owner)

{
 TIniFile *ini;
 ini = new TIniFile( ChangeFileExt( Application->ExeName, ".INI" ) );
 Top = ini->ReadInteger( "Form", "Top", 100 );
 Left = ini->ReadInteger( "Form", "Left", 100 );
 Caption = ini->ReadString( "Form", "Caption",
 "Default Caption" );
 ini->ReadBool( "Form", "InitMax", false ) ?
 WindowState = wsMaximized :
 WindowState = wsNormal;
 delete ini;
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)

{
 TIniFile *ini;
 ini = new TIniFile(ChangeFileExt( Application->ExeName, ".INI" ) );
 ini->WriteInteger( "Form", "Top", Top );
 ini->WriteInteger( "Form", "Left", Left );
 ini->WriteString ( "Form", "Caption", Caption );
 ini->WriteBool ( "Form", "InitMax",
 WindowState == wsMaximized );
 delete ini;
}


ini文件内容是
[Form]

Top=185
Left=280
Caption=Default Caption
InitMax=0

你可能感兴趣的:(ini)