MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / LoadFromKey

Method LoadFromKey

WinArk/Settings.cpp:11–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11bool Settings::LoadFromKey(PCWSTR registryPath) {
12 if (registryPath == nullptr)
13 registryPath = _path.c_str();
14 else
15 _path = registryPath;
16
17 ATLASSERT(registryPath);
18 if (registryPath == nullptr)
19 return false;
20
21 CRegKey key;
22 if (ERROR_SUCCESS != key.Open(HKEY_CURRENT_USER, registryPath))
23 return false;
24
25 WCHAR name[64];
26 BYTE value[512];
27 DWORD type;
28 for (DWORD i = 0;; ++i) {
29 DWORD lname = _countof(name), lvalue = sizeof(value);
30 auto error = ::RegEnumValue(key, i, name, &lname, nullptr, &type, value, &lvalue);
31 if (ERROR_NO_MORE_ITEMS == error)
32 break;
33
34 if (error != ERROR_SUCCESS)
35 continue;
36
37 auto it = _settings.find(name);
38 if (it == _settings.end())
39 _settings.insert({ name,Setting(name,(BYTE*)value,lvalue,(SettingType)type) });
40 else
41 it->second.Set(value, lvalue);
42 }
43 return true;
44}
45
46bool Settings::SaveToKey(PCWSTR registryPath) const {
47 if (registryPath == nullptr)

Callers

nothing calls this directly

Calls 4

SettingClass · 0.85
OpenMethod · 0.45
endMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected