VC中对CString 的读写(ini文件)
//此处为写
CString a,b;
a="as";
b="sa"
CString strFileName;
CString strKeyName;
CString strKeyValue;
CString strpath;
strpath="C:\\";
strFileName=strpath+"AllParameter.ini";
strKeyName="A";
strKeyValue=a;
::WritePrivateProfileString("ModelParameter",strKeyName,strKeyValue,strFileName);
strKeyName="B";
strKeyValue=b;
::WritePrivateProfileString("ModelParameter",strKeyName,strKeyValue,strFileName);
//此处为读
CStirng a,b;
CString strFileName;
CString strKeyName;
CString strKeyValue;
CString strpath;
strpath="C:\\";
strFileName=strpath+"AllParameter.ini";
strKeyName="A";
::GetPrivateProfileString("ModelParameter",strKeyName,0,strKeyValue.GetBuffer(MAX_PATH),MAX_PATH,strFileName);
a=strKeyValue;
strKeyName="B";
::GetPrivateProfileString("ModelParameter",strKeyName,0,strKeyValue.GetBuffer(MAX_PATH),MAX_PATH,strFileName);
b=strKeyValue;