SERVICE_TABLE_ENTRY Dispatch[] = { {"MyService", ServiceMain}, {NULL,
NULL} };
if (!StartServiceCtrlDispatcher(Dispatch))
{
//We were started from the command line
}
else
{
//We were start through Service Control Manager
}
When started as a service there's no problems but when started from
the command line, the StartServiceCtrlDispatcher() line of code can
take up to 20 seconds to return! What is going on here that it's
waiting for?
Advice appreciated
Zach
MSDN says that :
If StartServiceCtrlDispatcher succeeds, it connects the calling thread to
the service control manager and does not return until all running services
in the process have entered the SERVICE_STOPPED state.
Thanks for the response, but I'm not sure if I understand how this
applies to the question I asked. For one thing, the call isn't
succeeding because I'm running it from the console and not as a
service. If the problem could have been answered by the MSDN docs I
wouldn't have posted :(