void
CFileTextDoc::OnIniread()
{
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);
}
void
CFileTextDoc::OnIniwrite()
{
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);
}