示例#1
0
//将变量保存到文件中
VOID CVariableSystem::SaveVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf)
{
	const CHAR* szSystemCfg = "./WXSystem.cfg";
	UINT dwFileAttr = GetFileAttributes(szSystemCfg);

	if(FILE_ATTRIBUTE_READONLY & dwFileAttr)
	{
		SetFileAttributes(szSystemCfg, dwFileAttr&(~FILE_ATTRIBUTE_READONLY));
	}
	VARIABLE_MAP::iterator it;
	for(it=mapBuf.begin(); it!=mapBuf.end(); it++)
	{
		if(it->second.bTemp == FALSE)
		{
			::WritePrivateProfileString("Variable", it->first.c_str(), it->second.vValue.c_str(), szSystemCfg);
		}
	}
	if(FILE_ATTRIBUTE_READONLY & dwFileAttr)
	{
		SetFileAttributes(szSystemCfg, dwFileAttr);
	}

}
示例#2
0
void CVariableSystem::SaveAcountVariables(void)
{
	if(GetAs_Int("GameServer_ConnectDirect") == 1)
		return;
	STRING szAccount,szUser,szGame_Connect;
	VARIABLE_MAP userCfgMap;
	VARIABLE_MAP::const_iterator it = m_mapCurrent.begin();
	for(;it != m_mapCurrent.end();it++)
	{
		STRING key = (*it).first;
		VARIABLE val  = (*it).second;
		userCfgMap[key] = val;
	}
	VARIABLE_MAP::iterator itFind = userCfgMap.find("View_Fanhunjiao");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_Fanhunjiao"));

	itFind = userCfgMap.find("View_Aplomb");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_Aplomb"));

	itFind = userCfgMap.find("Login_Area");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("Login_Area"));

	itFind = userCfgMap.find("Login_Server");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("Login_Server"));

	itFind = userCfgMap.find("Login_Provider");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("Login_Provider"));

	itFind = userCfgMap.find("View_Resoution");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_Resoution"));

	itFind = userCfgMap.find("View_PiFeng");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_PiFeng"));

	itFind = userCfgMap.find("View_FullScreen");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_FullScreen"));

	itFind = userCfgMap.find("View_MaxWindow");
	if(itFind != userCfgMap.end())
		userCfgMap.erase(userCfgMap.find("View_MaxWindow"));

	GetVariable("Game_Account",szAccount);
	GetVariable("Character_Name",szUser);
	if(szAccount.empty() || szUser.empty()) return;

	char szFullPath[MAX_PATH] = {0};

	STRING szAccEncrypt;
	StringEncrypt( szAccount, szAccEncrypt ); //加密帐号名
	_snprintf(szFullPath, MAX_PATH, "..\\Accounts\\%s", szAccEncrypt.c_str());
	//_snprintf(szFullPath, MAX_PATH, "..\\Accounts\\%s", szAccount.c_str());
	::CreateDirectory(szFullPath, NULL);

	char szFullFileName[MAX_PATH] = {0};
	STRING szUserEncrypt;
	StringEncrypt( szUser, szUserEncrypt ); //加密帐号名
	_snprintf(szFullFileName, MAX_PATH, "%s\\%s.pfc", szFullPath, szUserEncrypt.c_str());
	//_snprintf(szFullFileName, MAX_PATH, "%s\\%s.pfc", 
	//	szFullPath, szUser.c_str());
	::DeleteFile(szFullFileName);
	SaveVariable(szFullFileName, userCfgMap);
}