dadamoney

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 
//包含文件

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

posted on 2009-07-31 10:01  dadamoney  阅读(2661)  评论(0编辑  收藏  举报