2023-05-30 11:11:24 +00:00
|
|
|
#include "app_cfg.h"
|
|
|
|
#include "base/HGDef.h"
|
|
|
|
#include "base/HGInc.h"
|
|
|
|
#include "base/HGUtility.h"
|
|
|
|
#include "base/HGIni.h"
|
|
|
|
#include "HGString.h"
|
|
|
|
|
|
|
|
std::string getCfgValue(const char *appName, const char *key, const std::string &def)
|
|
|
|
{
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
|
|
|
strcat(cfgPath, "config.ini");
|
|
|
|
|
|
|
|
HGChar value[512] = {0};
|
|
|
|
HGBase_GetProfileString(cfgPath, appName, key, def.c_str(), value, 512);
|
|
|
|
return StdStringToUtf8(value).c_str();
|
|
|
|
}
|
|
|
|
|
2023-06-02 06:34:35 +00:00
|
|
|
bool getCfgValue(const char *appName, const char *key, bool def)
|
|
|
|
{
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
|
|
|
strcat(cfgPath, "config.ini");
|
|
|
|
|
|
|
|
HGInt value = 0;
|
|
|
|
HGBase_GetProfileInt(cfgPath, appName, key, (HGInt)def, &value);
|
|
|
|
return (bool)value;
|
|
|
|
}
|
|
|
|
|
2023-05-30 11:11:24 +00:00
|
|
|
void saveCfgValue(const char *appName, const char *key, const std::string &value)
|
|
|
|
{
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
|
|
|
HGBase_CreateDir(cfgPath);
|
|
|
|
strcat(cfgPath, "config.ini");
|
|
|
|
|
|
|
|
HGBase_SetProfileString(cfgPath, appName, key, value.c_str());
|
|
|
|
}
|
2023-06-02 06:34:35 +00:00
|
|
|
|
|
|
|
void saveCfgValue(const char *appName, const char *key, bool value)
|
|
|
|
{
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
|
|
|
HGBase_CreateDir(cfgPath);
|
|
|
|
strcat(cfgPath, "config.ini");
|
|
|
|
|
|
|
|
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
|
|
|
|
}
|