Browse Source

Added enumerate_registry_values().

New function to retrieve values under a key.
Iain Patterson 5 years ago
parent
commit
70c205435a
2 changed files with 9 additions and 0 deletions
  1. 8 0
      registry.cpp
  2. 1 0
      registry.h

+ 8 - 0
registry.cpp

@@ -67,6 +67,14 @@ int create_messages() {
   return 0;
 }
 
+long enumerate_registry_values(HKEY key, unsigned long *index, TCHAR *name, unsigned long namelen) {
+  unsigned long type;
+  unsigned long datalen = namelen;
+  long error = RegEnumValue(key, *index, name, &datalen, 0, &type, 0, 0);
+  if (error == ERROR_SUCCESS) ++*index;
+  return error;
+}
+
 int create_parameters(nssm_service_t *service, bool editing) {
   /* Try to open the registry */
   HKEY key = open_registry(service->name, KEY_WRITE);

+ 1 - 0
registry.h

@@ -43,6 +43,7 @@ long open_registry(const TCHAR *, const TCHAR *, REGSAM sam, HKEY *, bool);
 HKEY open_registry(const TCHAR *, const TCHAR *, REGSAM sam, bool);
 HKEY open_registry(const TCHAR *, const TCHAR *, REGSAM sam);
 HKEY open_registry(const TCHAR *, REGSAM sam);
+long enumerate_registry_values(HKEY, unsigned long *, TCHAR *, unsigned long);
 int create_messages();
 int create_parameters(nssm_service_t *, bool);
 int create_exit_action(TCHAR *, const TCHAR *, bool);