added function to get/set registry DWORD values

pull/1/head
Heiko Hund 16 years ago
parent 1e2d5f80c5
commit 66280bca2c

@ -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) int SetRegistryValue(HKEY regkey, const char *name, char *data)
{ {
/* set a registry string */ /* set a registry string */
@ -271,3 +280,14 @@ int SetRegistryValue(HKEY regkey, const char *name, char *data)
return(1); 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;
}

@ -23,5 +23,7 @@ int GetRegistryKeys();
//int SetRegistryKeys(); //int SetRegistryKeys();
int GetRegKey(const char name[], char data[], const char default_data[], DWORD len); 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 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 SetRegistryValue(HKEY regkey, const char *name, char *data);
int SetRegistryValueNumeric(HKEY regkey, const char *name, DWORD data);

Loading…
Cancel
Save