读写配置文件
来源:互联网 发布:正整数分解质因数算法 编辑:程序博客网 时间:2024/05/18 02:12
// 写配置文件#include <iostream>#include <Windows.h>#include <tchar.h>#include <string.h>using std::cout;using std::endl;int main(){ char lpPath[MAX_PATH] = { 0 }; int nLen = strlen("D:\\myIniFile.ini"); // 16 nLen = strlen(lpPath); // 0 strcpy_s(lpPath, strlen("D:\\myIniFile.ini") + 1, "D:\\myIniFile.ini"); WritePrivateProfileStringA( "LiMing", "Sex", "Man", lpPath); WritePrivateProfileStringA("LiMing", "Age", "20", lpPath); WritePrivateProfileStringA("Fangfang", "Sex", "Woman", lpPath); WritePrivateProfileStringA("Fangfang", "Age", "18", lpPath); cout << "success" << endl; cout << endl; // 读取配置文件 cout << "LiMing personal information." << endl; char Sex[20] = { 0 }; GetPrivateProfileStringA( "LiMing", // 应用程序名,节名 "Sex", // 键名 "", // 默认返回值,如果没有获取到键值 Sex, // 获取返回键值 6, // 缓冲区大小 lpPath); // INI文件的路径 cout << Sex << endl; int Age = 0; Age = GetPrivateProfileIntA( "LiMing", // 应用程序名,节名 "Age", // 键名 0, // 默认返回值,如果没有获取到键值 lpPath); // INI文件的路径 cout << Age << endl; cout << "Fangfang personal information." << endl; GetPrivateProfileStringA("Fangfang", "Sex", "", Sex, 6, lpPath); cout << Sex << endl; Age = 0; Age = GetPrivateProfileIntA("Fangfang", "Age", 0, lpPath); cout << Age << endl; system("pause"); return 0;}
阅读全文
0 0
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 配置文件读写
- 读写配置文件
- 读写配置文件
- 读写配置文件
- 读写配置文件
- C#读写配置文件
- 读写配置文件app.config
- 读写配置文件app.config
- Symbian中读写配置文件
- C语言读写配置文件
- 读写配置文件app.config
- oracle DBaaS 数据库云服务实践之一添加主机失败解决
- 开发H5游戏引擎的选择:Egret或Laya?
- 优先队列实现成员的增减
- 1127. ZigZagging on a Tree (30)[二叉树构建-dfs-bfs]
- Linux安装MySql:(一)通用二进制方式安装
- 读写配置文件
- 编程书籍网站 http://www.fatiao.space [记录]
- 三维坐标系的旋转矩阵
- Xml与web易出现的错误
- jquery实现tab切换
- React对象表现形式以及其它特性
- 单片机之流水灯
- java集合
- (C#)WPF页面显示图片