Browse Source

added function to get/set registry DWORD values

pull/1/head
Heiko Hund 16 years ago
parent
commit
66280bca2c
  1. 20
      registry.c
  2. 2
      registry.h

20
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;
}

2
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);

Loading…
Cancel
Save