首页 > 编程语言 > 详细

MFC读写配置文件

时间:2015-04-21 14:28:37      阅读:227      评论:0      收藏:0      [点我收藏+]

 

void CFileTextDoc::OnIniread()
{
// TODO: Add your command handler code here
CString strStudName;
 
int nStudAge;
 
GetPrivateProfileString("Info","Name","默认姓名",strStudName.GetBuffer(MAX_PATH),MAX_PATH,"./student.ini");
 
//读入整型值
nStudAge = GetPrivateProfileInt("Info","Age",10,"./student.ini");
CString strAge;
strAge.Format("%d",nStudAge);
 
MessageBox(NULL,strStudName,_T(""),MB_OK);
 
MessageBox(NULL,strAge,_T(""),MB_OK);
}
 
//将信息写入.ini文件中
void CFileTextDoc::OnIniwrite()
{
// TODO: Add your command handler code here
CString strName,strTemp;
 
int nAge;
 
strName="张三";
 
nAge=12;
 
WritePrivateProfileString("Info","Name",strName,"./student.ini");
 
strTemp.Format("%d",nAge);
 
WritePrivateProfileString("Info","Age",strTemp,"./student.ini");
 
WritePrivateProfileString("Info","Sex","男","./student.ini");
 
WritePrivateProfileString("Record","Male","女","./student.ini");
 
MessageBox(NULL,"文件写入成功!",_T(""),MB_OK);
   
}

 

MFC读写配置文件

原文:http://www.cnblogs.com/lvdongjie/p/4444108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!