- LPTSTR lpPath = new char[MAX_PATH];
- strcpy(lpPath, "D:\\IniFileName.ini");
- WritePrivateProfileString("LiMing", "Sex", "Man", lpPath); //会创建相应文件
- WritePrivateProfileString("LiMing", "Age", "20", lpPath);
- WritePrivateProfileString("Fangfang", "Sex", "Woman", lpPath);
- WritePrivateProfileString("Fangfang", "Age", "21", lpPath);
- delete [] lpPath;
- INI文件如下:
- [LiMing]
- Sex=Man
- Age=20
- [Fangfang]
- Sex=Woman
- Age=21
- 读INI文件:
- LPTSTR lpPath = new char[MAX_PATH];
- LPTSTR LiMingSex = new char[6];
- int LiMingAge;
- LPTSTR FangfangSex = new char[6];
- int FangfangAge;
- strcpy(lpPath, "..\\IniFileName.ini");
- GetPrivateProfileString("LiMing", "Sex", "", LiMingSex, 6, lpPath);
- LiMingAge = GetPrivateProfileInt("LiMing", "Age", 0, lpPath);
- GetPrivateProfileString("Fangfang", "Sex", "", FangfangSex, 6, lpPath);
- FangfangAge = GetPrivateProfileInt("Fangfang", "Age", 0, lpPath);
- delete [] lpPath;
ini文件读写
最新推荐文章于 2024-04-26 09:30:15 发布