问题描述
- 如何把获取的路径写入ini文件?
-
void CtestDlg::OnClickedWriteReadButton1()
{
// TODO: Add your control notification handler code here
CString FilePathName1,filter;filter="??(*.??)||*.??||*.*||(*)"; CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("All Files (*.*)|*.*||"), NULL);
if (dlg.DoModal()==IDOK)
{
FilePathName1 = dlg.GetPathName();
m_Croad = FilePathName1;UpdateData(FALSE);
}//这是获取的路径的代码
}
void CtestDlg::OnClickedAdkButton()
{
// TODO: Add your control notification handler code hereCIniFile configFile;
configFile.SetFileName("ServerConfig.ini");
configFile.ReadIniFile();int nRemotePortNumber = configFile.GetInt("RemoteServer","Port",0);
string sRemoteIP = configFile.GetString("RemoteServer","IP","");
int nLocalPortNumber = configFile.GetInt("LocalServer","Port",0);
string sLocalIP = "127.0.0.1";//configFile.GetString("LocalServer","IP","");CString sProtocal = (configFile.GetString("Protocal","Type","udp"));//.MakeLower();/**/
CString sAddress = configFile.GetString("LoclaAddress","Address","");
m_Adkroad=sAddress;
UpdateData(FALSE);
}//这是ini文件的一些配置
[LoclaAddress]
Address=E:
//这个是ini文件中的,上边代码怎么写才能把获取的路径保存到ini文件中,代替E:
解决方案
读取和写入Windows的INI文件
读取文档-写入ini文件中
解决方案二:
windows有提供操作ini文件的API,可以参考这个http://blog.csdn.net/rayborn1105/article/details/8192142
解决方案三:
http://www.cnblogs.com/afarmer/archive/2012/03/31/2427243.html