开发平台(Platform): (Ex: Win10, Linux, ...)
Win10
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
vs2019
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
问题(Question):
各位大大好,最近因为在做设定档案的取值,
之前我的作法都是采用:GetPrivateProfileString(只需要输入Section与KenName即可)
之后跟同事开会,有注意到一个问题,如果资料量太大,一个一个输入效率太低。
所以我找到有关于GetPrivateProfileSection
(只需要输入Section,即可显示此类组所有KeyName与KeyValue)
测试的时候,确认有资料,但显示为什么都是一堆我不懂的数字.....?
喂入的资料(Input):
下图是我的设定档案的内容,主要是抓取"System Access"、"Registry Values"
这两大类,我先实验只抓取"System Access"这个类组的资料
https://imgur.com/37gMtJw
预期的正确结果(Expected Output):
这边我预想是显示:
MinimumPasswordAge = 0
MaximumPasswordAge = 42
MinimumPasswordLength = 0
PasswordComplexity = 0
PasswordHistorySize = 0
LockoutBadCount = 0
RequireLogonToChangePassword = 0
ForceLogoffWhenHourExpire = 0
NewAdministratorName = "Administrator"
NewGuestName = "Guest"
ClearTextPassword = 0
LSAAnonymousNameLookup = 0
EnableAdminAccount = 0
EnableGuestAccount = 0
错误结果(Wrong Output):
下图是直接显示的结果,不懂为什么出现一个我看不懂的数值
https://imgur.com/FKSnk9U
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
#include <iostream>
#include <windows.h>
#include <fstream>
#include <vector>
#include <stdio.h>
#include <string>
#include <sstream>
#include <tchar.h>
#include <shellapi.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <atlstr.h>
#include <codecvt>
int main(void)
{
TCHAR strRetunrStringBuf[512];
TCHAR* strNavi[512];
GetPrivateProfileSection(_T("System Access"), strRetunrStringBuf, 512, Get_LGPO01_FilePath());
cout<< strRetunrStringBuf <<endl;
}
//Get_LGPO01_FilePath是我预先写好档案路径的位置,所以可以直接使用
补充说明(Supplement):
一开始我以为是我方向错误,我检查了strRetunrStringBuf内有显示的东西:
https://imgur.com/VzpgO87
它内容其实是有抓到我指定类组的资料,并以'\0'作为区分
https://imgur.com/i0aesxx
但我不不懂他这一整个内容呈现会是一个奇怪的数字???
想询问各位大神们,是我哪边搞错了吗?