收藏 分享(赏)

MFC读写配置文件.doc

上传人:yjrm16270 文档编号:6817795 上传时间:2019-04-23 格式:DOC 页数:2 大小:50.50KB
下载 相关 举报
MFC读写配置文件.doc_第1页
第1页 / 共2页
MFC读写配置文件.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、读写配置文件 ini首先介绍两个函数:读取 ini 文件:DWORD GetPrivateProfileString(LPCTSTR lpAppName, / points to section nameLPCTSTR lpKeyName, / points to key nameLPCTSTR lpDefault, / points to default stringLPTSTR lpReturnedString, / points to destination bufferDWORD nSize, / size of destination bufferLPCTSTR lpFileName

2、 / points to initialization filename);参数说明:lpAppName :ini 文件中的一个字段名lpKeyName :lpAppName 下的一个键名,也就是具体的变量名lpDefault :如果没有其前两个参数值,则将此值赋给变量lpReturnedString :接收 INI 文件中的值的 CString 对象,即目的缓存器nSize :目的缓存器的大小lpFileName :完整的 INI 文件路径名写入 ini 文件:BOOL WritePrivateProfileString(LPCTSTRlpAppName, / section nameLPC

3、TSTRlpKeyName, / key nameLPCTSTRlpString, / string to addLPCTSTRlpFileName / initialization file);参数说明:lpAppName :ini 文件中的一个字段名lpKeyName :lpAppName 下的一个键名,也就是具体的变量名lpString :是键值,也就是变量的值,必须为 LPCTSTR 或 CString 类型lpFileName :完整的 INI 文件路径名读取整型值:UINT GetPrivateProfileInt(LPCTSTRlpAppName, / section nameL

4、PCTSTRlpKeyName, / key nameINTnDefault, / return value if key name not foundLPCTSTRlpFileName / initialization file name);实例:写入:CString StrName,Strtemp;int nAge;char filename20 = “;StrName = “jacky“;nAge = 13;WritePrivateProfileString(“Student“,“Name“,StrName,“ressetting.ini“);读取:CString SName;GetPrivateProfileString(“Student“,“Name“,“DefaultName“,SName.GetBuffer(100),100,“ressetting.ini“);SName.ReleaseBuffer();MessageBox(SName);

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报