//包含文件

#include <inifiles.hpp>

//写文件

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

//读文件

if(FileExists(ExtractFilePath(Application->ExeName)+"config.cfg"))//检测文件是否存在
{
TIniFile *ini;
ini=new TIniFile(ChangeFileExt(ExtractFilePath(Application->ExeName),"config.cfg"));

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;
}
else
{
ShowMessage("文件不存在");
}

相关文章:

  • 2022-03-04
  • 2021-07-30
  • 2021-09-13
  • 2021-12-14
  • 2021-08-28
猜你喜欢
  • 2022-12-23
  • 2021-10-15
  • 2021-12-24
  • 2021-12-18
  • 2021-09-29
  • 2021-12-30
相关资源
相似解决方案