X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=86eaaf508275fc8ef93fe3c22b71210118eb2af0;hb=838c282576cff8e2f0467eab8965ccaee39075f5;hp=e3817a4bc1560c55c851fbe9a655039e1713c5cf;hpb=e26682667e15433cad518e622c3c061840b487dd;p=nssm.git diff --git a/registry.cpp b/registry.cpp index e3817a4..86eaaf5 100644 --- a/registry.cpp +++ b/registry.cpp @@ -822,8 +822,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);