C++中通过MFC对ini初始化,配置文件的读写使用

来源:互联网 发布:网络的危害英语作文 编辑:程序博客网 时间:2024/06/06 20:17

软件重新打开需要保存上一次关闭时的配置参数时,非常适用。

CString filepath ;GetModuleFileName(NULL,filepath.GetBuffer(MAX_PATH),MAX_PATH);//得到运行文件路径filepath.ReleaseBuffer();filepath = filepath.Left(filepath.ReverseFind('\\'));//返回上一级filepath = filepath.Left(filepath.ReverseFind('\\'));//返回级数根据自己ini文件位置filepath +=_T("\\infig.ini");//找到自己的配置文件g_LangId = GetPrivateProfileInt( _T("Option"),_T("LanguageID"),-1, filepath ); CString strKeyValue;//写入的参数WritePrivateProfileString (_T("Option"), _T("LanguageID"),strKeyValue,filepath );


GetPrivateProfileInt与WritePrivateProfileString 的使用网上查找。

原创粉丝点击