if (NULL == (service = CreateService(mgr, wservice_name, wservice_name, GENERIC_READ, SERVICE_WIN32_OWN_PROCESS,
#include "zbxwinservice.h"
#define EVENTLOG_REG_PATH TEXT("SYSTEM\\CurrentControlSet\\Services\\EventLog\\")
static SERVICE_STATUS serviceStatus;
static SERVICE_STATUS_HANDLE serviceHandle;
#define ZBX_APP_STOPPED 0
#define ZBX_APP_RUNNING 1
static int application_status = ZBX_APP_RUNNING;
static zbx_on_exit_t zbx_on_exit_cb;
static zbx_get_config_str_f get_zbx_service_name_cb = NULL;
static zbx_get_config_str_f get_zbx_event_source_cb = NULL;
return application_status;
application_status = ZBX_APP_STOPPED;
void zbx_free_service_resources(int ret);
static void parent_signal_handler(int sig)
zabbix_log(LOG_LEVEL_INFORMATION, "Got signal. Exiting ...");
static VOID WINAPI ServiceCtrlHandler(DWORD ctrlCode)
serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
serviceStatus.dwCurrentState = SERVICE_RUNNING;
serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
serviceStatus.dwWin32ExitCode = 0;
serviceStatus.dwServiceSpecificExitCode = 0;
serviceStatus.dwCheckPoint = 0;
serviceStatus.dwWaitHint = 0;
case SERVICE_CONTROL_STOP:
zabbix_log(LOG_LEVEL_INFORMATION, "Zabbix Agent received stop request.");
case SERVICE_CONTROL_SHUTDOWN:
zabbix_log(LOG_LEVEL_INFORMATION, "Zabbix Agent received shutdown request.");
zabbix_log(LOG_LEVEL_DEBUG, "Zabbix Agent received request:%u.", ctrlCode);
case SERVICE_CONTROL_STOP: