Starting service failed
Posted on 2003-12-10
I am writing a service using the helper classes from the book "Programming Server-Size Applications for Microsoft Windows 2000" by Jeffrey Richter, Jason D. Clark. Starting the service in TimeServer book sample looks like this:
hpipe = CreateNamedPipe(TEXT("\\\\.\\pipe\\TimeService"),
PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE, 1, sizeof(st), sizeof(st), 1000, NULL);
Since this is just a sample, there is no error handling and service start is supposed to succeed always. Appropriate code fragment from my program:
if ( g_ServerSocket.Start(PORT_NUMBER) )
g_EventLog.ReportEvent(EVENTLOG_INFORMATION_TYPE, CAT_APPEXECSTATUS, MSG_APPSTART);
// What to do here ???
I want to report error to SCM. Currently it tries to start my service a lot of time, I cannot say "Operation failed". Service remains in the state "Starting".