[ImageResizer] Migrate settings from registry to JSON. (#2604)

* Migrate ImageResizer settings from registry to JSON.

* Update last loaded time read/write IO operations.

* Rename registry helper functions.
This commit is contained in:
vldmr11080
2020-05-05 09:00:50 +02:00
committed by GitHub
parent c14c51f551
commit 2b4b23f726
5 changed files with 140 additions and 69 deletions

View File

@@ -3,14 +3,36 @@
class CSettings
{
public:
static bool GetEnabled();
static bool SetEnabled(_In_ bool enabled);
CSettings();
inline bool GetEnabled()
{
Reload();
return settings.enabled;
}
inline void SetEnabled(bool enabled)
{
settings.enabled = enabled;
Save();
}
void Save();
void Load();
private:
static bool GetRegBoolValue(_In_ PCWSTR valueName, _In_ bool defaultValue);
static bool SetRegBoolValue(_In_ PCWSTR valueName, _In_ bool value);
static bool SetRegDWORDValue(_In_ PCWSTR valueName, _In_ DWORD value);
static DWORD GetRegDWORDValue(_In_ PCWSTR valueName, _In_ DWORD defaultValue);
static bool SetRegStringValue(_In_ PCWSTR valueName, _In_ PCWSTR value);
static bool GetRegStringValue(_In_ PCWSTR valueName, __out_ecount(cchBuf) PWSTR value, DWORD cchBuf);
};
struct Settings
{
bool enabled{ true };
};
void Reload();
void MigrateFromRegistry();
void ParseJson();
Settings settings;
std::wstring jsonFilePath;
FILETIME lastLoadedTime;
};
CSettings& CSettingsInstance();