X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=258b96abe598ddd53c21a7b1666e0db950922a9b;hb=651295f206ecac10db9a24200e67762d24166db5;hp=e3817a4bc1560c55c851fbe9a655039e1713c5cf;hpb=e26682667e15433cad518e622c3c061840b487dd;p=nssm.git diff --git a/registry.cpp b/registry.cpp index e3817a4..258b96a 100644 --- a/registry.cpp +++ b/registry.cpp @@ -353,12 +353,10 @@ int set_string(HKEY key, TCHAR *value, TCHAR *string, bool expand) { int set_string(HKEY key, TCHAR *value, TCHAR *string) { return set_string(key, value, string, false); - return 1; } int set_expand_string(HKEY key, TCHAR *value, TCHAR *string) { return set_string(key, value, string, true); - return 1; } /* @@ -524,7 +522,7 @@ long open_registry(const TCHAR *service_name, const TCHAR *sub, REGSAM sam, HKEY HKEY open_registry(const TCHAR *service_name, const TCHAR *sub, REGSAM sam, bool must_exist) { HKEY key; - long error = open_registry(service_name, sub, sam, &key, true); + long error = open_registry(service_name, sub, sam, &key, must_exist); return key; } @@ -822,8 +820,15 @@ int get_hook(const TCHAR *service_name, const TCHAR *hook_event, const TCHAR *ho log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, _T("hook registry"), _T("get_hook()"), 0); return 1; } - HKEY key = open_registry(service_name, registry, KEY_READ, false); - if (! key) return 1; + HKEY key; + long error = open_registry(service_name, registry, KEY_READ, &key, false); + if (! key) { + if (error == ERROR_FILE_NOT_FOUND) { + ZeroMemory(buffer, buflen); + return 0; + } + return 1; + } int ret = expand_parameter(key, (TCHAR *) hook_action, buffer, buflen, true, false);