#include <inifiles.hpp> #include <iostream> using namespace std;
int _tmain(int argc, _TCHAR* argv[]) { ? ?//TIniFile *pIniFile = new TIniFile(ExtractFilePath(Application->ExeName)+"myTest.ini");// ?? ? TIniFile *pIni = new TIniFile("c:\\myTest.ini");// ?? ? pIni->WriteString("张三","籍贯","重庆"); ?? ? pIni->WriteInteger("张三","年龄",18); ?? ? pIni->WriteFloat("张三","体重",60.5); ?? ? pIni->WriteBool("张三","婚否",false); ?? ? pIni->WriteString("李四","籍贯","江西"); ?? ? pIni->WriteInteger("李四","年龄",23); ?? ? pIni->WriteFloat("李四","体重",63); ?? ? pIni->WriteBool("李四","婚否",true);
?? ? AnsiString str1; ?? ? AnsiString old; ?? ? float weight; ?? ? bool IsMarried; ?? ? std::cout<<"张三:" <<std::endl; ?? ? str1=pIni->ReadString("张三","籍贯","未知");cout<<str1<<endl; ?? ? old=pIni->ReadInteger("张三","年龄",0);cout<<old<<endl; ?? ? weight=pIni->ReadFloat("张三","体重",0);cout<<weight<<endl; ?? ? IsMarried=pIni->ReadBool("张三","婚否",false);cout<<IsMarried<<endl; ?? ? cout<<"李四:" <<endl; ?? ? str1=pIni->ReadString("李四","籍贯","未知");cout<<str1<<endl; ?? ? old=pIni->ReadInteger("李四","年龄",0);cout<<old<<endl; ?? ? weight=pIni->ReadFloat("李四","体重",0);cout<<weight<<endl; ?? ? IsMarried=pIni->ReadBool("李四","婚否",false);cout<<IsMarried<<endl; ?? ? delete pIni; ?? ? system("pause"); ?? ?return 0; }
|