VC++中,配置文件的读写操作
来源:互联网 发布:linux usleep range 编辑:程序博客网 时间:2024/06/04 18:33
配置文件写操作:
(1)获得应用程序路径的 函数:
CString CAppFullPath::AppPath()
{
CString strModulePath;
DWORD dwResult = ::GetModuleFileName(NULL,strModulePath.GetBuffer(MAX_PATH),MAX_PATH);
ASSERT(dwResult);
strModulePath.ReleaseBuffer();
strModulePath = strModulePath.Left(strModulePath.ReverseFind(_T('//')) + 1);
return strModulePath;
}
(2)获得配置文件路径:strtranspath=(应用程序路径) strModulePath+(文件名)*.ini
(3)写 .ini 配置文件: WritePrivateProfileString
BOOL writetransport=WritePrivateProfileString("Transrefer.ini","IPPORT",t_serverport,strtranspath);
"配置文件名" ,"字段" , 值 ,配置文件路径
ASSERT(writetransport); //验证是否为真,假时,程序卡在这,报错。
读取配置文件:
(1)CFileFind finder;//定义一标准类的对象
BOOL finded;
finded=finder.FindFile(transpath);//是否查找到文件 (内为文件路径)
if(finded)
{
GetPrivateProfileString("Transrefer.ini","IPADDRESS","127.0.0.1",serverip.GetBuffer(20),20,transpath);
文件中第一行的内容 ,字段 , 默认值, 存储地,20为字段长度, 文件路径
serverip.ReleaseBuffer();
}
- VC++中,配置文件的读写操作
- VC++中,配置文件的读写操作
- 配置文件的读写操作
- VC中注册表的读写修改操作
- VC配置文件ini的读写
- VC配置文件ini的读写
- VC配置文件ini的读写
- VC配置文件ini的读写
- VC配置文件ini的读写
- 在VC中读写ini配置文件的函数
- 在VC中读写ini配置文件
- 在VC中读写ini配置文件
- 在VC中读写ini配置文件
- 在VC中读写ini配置文件
- VC中存取配置文件的操作,Profile操作
- java配置文件的读写操作
- VC配置文件ini的读写(转载)
- VC配置文件ini的读写(转载)
- 反射 学习用例
- 百度篇——应聘百度新产品软件开发工程师及建议(一)——浅谈iGoogle
- Linux 内核剖析
- 高效率的3D图形数学库
- Fail to get datasource
- VC++中,配置文件的读写操作
- 百度篇——霸王面时递交的百度招聘会思考
- 《Agile Web Development with Rails》读书笔记(二)
- 让“显示所有的文件和文件夹”功能失效
- web开发,如何自动选定打印机进行打印(设置默认打印机打印)
- [技巧]如何绕过MaxtoCode的15天限制
- 金庸小说中的农业漏洞
- 灯火阑珊处
- SOA