diff --git a/registry.c b/registry.c index f77adaa..505ce5e 100644 --- a/registry.c +++ b/registry.c @@ -258,6 +258,15 @@ LONG GetRegistryValue(HKEY regkey, const char *name, char *data, DWORD len) } +LONG +GetRegistryValueNumeric(HKEY regkey, const char *name, DWORD *data) +{ + DWORD type; + DWORD size = sizeof(data); + LONG status= RegQueryValueEx(regkey, name, NULL, &type, (PBYTE) data, &size); + return (type == REG_DWORD ? status : ERROR_FILE_NOT_FOUND); +} + int SetRegistryValue(HKEY regkey, const char *name, char *data) { /* set a registry string */ @@ -271,3 +280,14 @@ int SetRegistryValue(HKEY regkey, const char *name, char *data) return(1); } + +int +SetRegistryValueNumeric(HKEY regkey, const char *name, DWORD data) +{ + LONG status = RegSetValueEx(regkey, name, 0, REG_DWORD, (PBYTE) &data, sizeof(data)); + if (status == ERROR_SUCCESS) + return 1; + + ShowLocalizedMsg(GUI_NAME, ERR_WRITE_REGVALUE, GUI_REGKEY_HKCU, name); + return 0; +} diff --git a/registry.h b/registry.h index d45a64f..199c432 100644 --- a/registry.h +++ b/registry.h @@ -23,5 +23,7 @@ int GetRegistryKeys(); //int SetRegistryKeys(); int GetRegKey(const char name[], char data[], const char default_data[], DWORD len); LONG GetRegistryValue(HKEY regkey, const char *name, char *data, DWORD len); +LONG GetRegistryValueNumeric(HKEY regkey, const char *name, DWORD *data); int SetRegistryValue(HKEY regkey, const char *name, char *data); +int SetRegistryValueNumeric(HKEY regkey, const char *name, DWORD data);