其他分享
首页 > 其他分享> > MFC之读取ini配置文件

MFC之读取ini配置文件

作者:互联网

#一次性加载的配置组数
[sunsz]
keynum=2

[01]
value=00000001
len=8

[02]
value=00000001
len=8

BOOL loadinit(LPVOID Lparam) {

	TCHAR path[MAX_PATH];
	ZeroMemory(path, MAX_PATH);
	GetModuleFileName(NULL, path, MAX_PATH);
	CString strPath = path;
	int pos = strPath.ReverseFind('\\');
	strPath = strPath.Left(pos);

	CFileFind finder;
	CString IniFile = strPath + "\\sunsz.ini";
	BOOL ifFind = finder.FindFile(IniFile);

	if (!ifFind)
	{
		return false;
	}

	CString head;
	CString seed;
	CString ini;
	CString iniencrypt;
	int len;
	int calnum = 0;
	int testlen = 0;
	int ways = 0;
	calnum = GetPrivateProfileInt("sunsz", "keynum", 1, IniFile);

	for (int i = 0; i < calnum; i++){
		CString num;
		CString diag;
		num.Format("%02d", i + 1);
		len = GetPrivateProfileInt(num, "len", 1, IniFile);
		GetPrivateProfileString(num, "value", "", head.GetBuffer(MAX_PATH), len+1, IniFile);
	}
return true;
}

 

标签:MFC,配置文件,int,CString,len,ini,PATH,IniFile,strPath
来源: https://blog.csdn.net/github_37687123/article/details/121301902