调试配置文件统一到debug.cfg

This commit is contained in:
gb 2023-03-27 12:06:40 +08:00
parent e6ead9b452
commit 9d6a7e5027
1 changed files with 29 additions and 9 deletions

View File

@ -3269,6 +3269,18 @@ void huagao_ds::init_support_caps_ex(void)
ADD_SANE_CAP(color_correction);
}
std::wstring huagao_ds::get_config_file(void)
{
char* tmp = getenv("LOCALAPPDATA");
if (tmp)
{
std::wstring str(L"");
std::string path(tmp);
path += std::string("\\") + PRODUCT_VENDOR + "Scan\\config\\debug.cfg";
return std::move(load_sane_util::ansi2unic(path.c_str()));
}
else
{
wchar_t path[MAX_PATH] = { 0 }, * name = NULL;
@ -3276,20 +3288,28 @@ std::wstring huagao_ds::get_config_file(void)
name = wcsrchr(path, L'\\');
if (name++ == NULL)
name = path;
wcscpy_s(name, _countof(path) - 1 - (name - path), L"first.cfg");
wcscpy_s(name, _countof(path) - 1 - (name - path), L"debug.cfg");
return path;
}
}
std::wstring huagao_ds::get_config_value(const wchar_t* sec, const wchar_t* key)
{
wchar_t v[256] = { 0 };
std::wstring cfg_f(get_config_file());
if(!cfg_f.empty())
GetPrivateProfileStringW(sec, key, L"", v, _countof(v) - 1, get_config_file().c_str());
return v;
}
DWORD huagao_ds::get_config_number(const wchar_t* sec, const wchar_t* key)
{
std::wstring cfg_f(get_config_file());
if (cfg_f.empty())
return 0;
else
return GetPrivateProfileIntW(sec, key, 0, get_config_file().c_str());
}
int huagao_ds::handle_scanner_event(int ev)