Win32Main: use FatalSystemError()

This commit is contained in:
Max Kellermann 2014-12-05 00:12:44 +01:00
parent 08bf4f74a9
commit e5ab456df3

View File

@ -29,8 +29,6 @@
#include <cstdlib> #include <cstdlib>
#include <atomic> #include <atomic>
#include <glib.h>
#include <windows.h> #include <windows.h>
static int service_argc; static int service_argc;
@ -82,19 +80,12 @@ service_dispatcher(gcc_unused DWORD control, gcc_unused DWORD event_type,
static void WINAPI static void WINAPI
service_main(gcc_unused DWORD argc, gcc_unused CHAR *argv[]) service_main(gcc_unused DWORD argc, gcc_unused CHAR *argv[])
{ {
DWORD error_code;
gchar* error_message;
service_handle = service_handle =
RegisterServiceCtrlHandlerEx(service_name, RegisterServiceCtrlHandlerEx(service_name,
service_dispatcher, nullptr); service_dispatcher, nullptr);
if (service_handle == 0) { if (service_handle == 0)
error_code = GetLastError(); FatalSystemError("RegisterServiceCtrlHandlerEx() failed");
error_message = g_win32_error_message(error_code);
FormatFatalError("RegisterServiceCtrlHandlerEx() failed: %s",
error_message);
}
service_notify_status(SERVICE_START_PENDING); service_notify_status(SERVICE_START_PENDING);
mpd_main(service_argc, service_argv); mpd_main(service_argc, service_argv);
@ -132,7 +123,6 @@ console_handler(DWORD event)
int win32_main(int argc, char *argv[]) int win32_main(int argc, char *argv[])
{ {
DWORD error_code; DWORD error_code;
gchar* error_message;
service_argc = argc; service_argc = argc;
service_argv = argv; service_argv = argv;
@ -149,9 +139,7 @@ int win32_main(int argc, char *argv[])
return mpd_main(argc, argv); return mpd_main(argc, argv);
} }
error_message = g_win32_error_message(error_code); FatalSystemError("StartServiceCtrlDispatcher() failed", error_code);
FormatFatalError("StartServiceCtrlDispatcher() failed: %s",
error_message);
} }
void win32_app_started() void win32_app_started()