NOEXPORT void WINAPI control_handler(DWORD controlCode) {
    switch(controlCode) {
    case SERVICE_CONTROL_INTERROGATE:
        break;
    case SERVICE_CONTROL_SHUTDOWN:
    case SERVICE_CONTROL_STOP:
        serviceStatus.dwCurrentState=SERVICE_STOP_PENDING;
        SetServiceStatus(serviceStatusHandle, &serviceStatus);
        PostMessage(hwnd, WM_COMMAND, IDM_EXIT, 0);
        return;
    case SERVICE_CONTROL_PAUSE:
        break;
    case SERVICE_CONTROL_CONTINUE:
        break;
    case SERVICE_CONTROL_USER+SIGNAL_RELOAD_CONFIG:
        signal_post(SIGNAL_RELOAD_CONFIG);
        break;
    case SERVICE_CONTROL_USER+SIGNAL_REOPEN_LOG:
        signal_post(SIGNAL_REOPEN_LOG);
        break;
    default:
        if(controlCode >= 128 && controlCode <= 255)
            break; /* user defined control code */
        else
            break; /* unrecognised control code */
    }
    SetServiceStatus(serviceStatusHandle, &serviceStatus);
}
NOEXPORT void WINAPI control_handler(DWORD controlCode) {
    switch(controlCode) {
    case SERVICE_CONTROL_INTERROGATE:
        break;
    case SERVICE_CONTROL_SHUTDOWN:
    case SERVICE_CONTROL_STOP:
        serviceStatus.dwCurrentState=SERVICE_STOP_PENDING;
        SetServiceStatus(serviceStatusHandle, &serviceStatus);
        PostMessage(hwnd, WM_COMMAND, IDM_EXIT, 0);
        return;
    case SERVICE_CONTROL_PAUSE:
        break;
    case SERVICE_CONTROL_CONTINUE:
        break;
    case SERVICE_CONTROL_USER+SIGNAL_RELOAD_CONFIG:
        signal_post(SIGNAL_RELOAD_CONFIG);
        break;
    case SERVICE_CONTROL_USER+SIGNAL_REOPEN_LOG:
        signal_post(SIGNAL_REOPEN_LOG);
        break;
    default:
        if(controlCode >= 128 && controlCode <= 255)
            break;  
        else
            break;  
    }
    SetServiceStatus(serviceStatusHandle, &serviceStatus);
}