读写ini

来源:互联网 发布:淘宝挤爆了 编辑:程序博客网 时间:2024/05/16 01:30
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/program_options/detail/convert.hpp>
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>

//#ifndef _UNICODE
//   #define Category  std::locale::category()
//   #define Tptree boost::property_tree::ptree
//   #define StringType std::string
//#else
   #define Category  program_options::detail::utf8_codecvt_facet()
   #define Tptree boost::property_tree::wptree
   #define StringType std::wstring
//#endif

//#define BOOST_ALL_DYN_LINK


using namespace std;
using namespace boost;


using namespace boost::property_tree;

int main()
{
    locale current_locale(locale(""),new Category);

    Tptree pt;

    boost::property_tree::ini_parser::read_ini("test.ini",pt,current_locale);
    StringType str = pt.get<StringType>(_T("BaseInfo.NotationProgram"));
    int AutoFocus =  pt.get<int>(_T("BaseInfo.AutoFocus"));
   
    pt.put<StringType>(_T("zhou.qing"),_T("好的"));

    boost::property_tree::ini_parser::write_ini("test.ini",pt,0,current_locale);

    TCHAR szData[50];
    _tcscpy(szData,str.c_str());

    std::system("pause");
    return 0;
}
0 0
原创粉丝点击