void ServiceMain(int argc, char** argv) { serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; serviceStatus.dwCurrentState = SERVICE_START_PENDING; serviceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; serviceStatus.dwWin32ExitCode = 0; serviceStatus.dwServiceSpecificExitCode = 0; serviceStatus.dwCheckPoint = 0; serviceStatus.dwWaitHint = 0; serviceStatusHandle = RegisterServiceCtrlHandlerW(serviceName, (LPHANDLER_FUNCTION)ControlHandler); if (serviceStatusHandle == (SERVICE_STATUS_HANDLE)0) return; serviceStatus.dwCurrentState = SERVICE_RUNNING; SetServiceStatus(serviceStatusHandle, &serviceStatus); SocketManager *sock = new SocketManager(); sock->start(); while (serviceStatus.dwCurrentState == SERVICE_RUNNING) { Sleep(1000); } }
int main(int argc, char **argv) { #if 1 SocketManager * mng = SocketManager::getInstance(); mng->init(); mng->start(); mng->fini(); #endif return 0; }