X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=imports.cpp;h=064ba27c589bf96367ac4c0f397cd7508a22eef7;hb=f13f3f81d7ad3ccda728d06f615ce5f724023f4e;hp=18c8bb0372484da8a919bba906ecfb0c10d8d82d;hpb=aece13df3cc7a17d5827cc59fc59c13538b52517;p=nssm.git diff --git a/imports.cpp b/imports.cpp index 18c8bb0..064ba27 100644 --- a/imports.cpp +++ b/imports.cpp @@ -36,7 +36,7 @@ FARPROC get_import(HMODULE library, const char *function, unsigned long *error) #else function_name = (TCHAR *) function; #endif - log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_GETPROCADDRESS_FAILED, function_name, error_string(*error), 0); + if (*error != ERROR_PROC_NOT_FOUND) log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_GETPROCADDRESS_FAILED, function_name, error_string(*error), 0); #ifdef UNICODE if (function_name) HeapFree(GetProcessHeap(), 0, function_name); #endif @@ -82,6 +82,15 @@ int get_imports() { } else if (error != ERROR_MOD_NOT_FOUND) return 5; + imports.user32 = get_dll(_T("user32.dll"), &error); + if (imports.user32) { + imports.RegisterPowerSettingNotification = (RegisterPowerSettingNotification_ptr) get_import(imports.user32, "RegisterPowerSettingNotification", &error); + if (! imports.RegisterPowerSettingNotification) { + if (error != ERROR_PROC_NOT_FOUND) return 9; + } + } + else if (error != ERROR_MOD_NOT_FOUND) return 8; + return 0; }