if (! ok) *buffer = default_value;\r
}\r
\r
-HKEY open_registry(const TCHAR *service_name, const TCHAR *sub, REGSAM sam) {\r
+HKEY open_registry(const TCHAR *service_name, const TCHAR *sub, REGSAM sam, bool must_exist) {\r
/* Get registry */\r
TCHAR registry[KEY_LENGTH];\r
HKEY key;\r
}\r
}\r
else {\r
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, registry, 0, sam, &key) != ERROR_SUCCESS) {\r
+ long error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, registry, 0, sam, &key);\r
+ if (error != ERROR_SUCCESS) {\r
+ if (error == ERROR_FILE_NOT_FOUND && ! must_exist) return 0;\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OPENKEY_FAILED, registry, error_string(GetLastError()), 0);\r
return 0;\r
}\r
return key;\r
}\r
\r
+HKEY open_registry(const TCHAR *service_name, const TCHAR *sub, REGSAM sam) {\r
+ return open_registry(service_name, sub, sam, true);\r
+}\r
+\r
HKEY open_registry(const TCHAR *service_name, REGSAM sam) {\r
- return open_registry(service_name, 0, sam);\r
+ return open_registry(service_name, 0, sam, true);\r
}\r
\r
int get_io_parameters(nssm_service_t *service, HKEY key) {\r
#define NSSM_REG_NO_CONSOLE _T("AppNoConsole")\r
#define NSSM_STDIO_LENGTH 29\r
\r
+HKEY open_registry(const TCHAR *, const TCHAR *, REGSAM sam, bool);\r
HKEY open_registry(const TCHAR *, const TCHAR *, REGSAM sam);\r
HKEY open_registry(const TCHAR *, REGSAM sam);\r
int create_messages();\r