Click to See Complete Forum and Search --> : NT Services


June 22nd, 1999, 12:08 PM
I have created and installed a service. When I open the SCM the service is in the list. However when I start the service the SCM posts the following error message
"The service process could not connect to the service controller". This would lead me to think the service was not installed, however I am able to get a handle to
the service by calling the OpenService() API, I am also able to unistall the service.
The above error message is being fed from the StartServiceCtrlDispatcher( ) function.
Here is the CreateService() call I am using to create my service...
if(h_SCM)
SC_HANDLE h_newService= CreateService(h_SCM,
g_ServiceName,
g_DisplayName,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START ,
SERVICE_ERROR_NORMAL,
_T("L:\\client\\ctransui\\cjhserv\\debug\\cjhserv.exe"),
NULL,
NULL,
NULL,
NULL,
NULL);
and here is the code I am using to start the dispatcher...
SERVICE_TABLE_ENTRY ServiceTable[] = {
{(LPTSTR) g_ServiceName, ServiceMain },
{NULL, NULL} };

if(!::StartServiceCtrlDispatcher(ServiceTable))
CServerObj::PrintError();

if anyone can offer me any insight into this I would be very grateful...Thanks you.

Jean-Marie Carl
June 25th, 1999, 06:28 AM
Hi,

Is it possible that your "L" drive is a network drive? I can imagine that this may be a problem.

Not a lot of info but maybe it helps.

Another suggestion: check out the NT-Service-Wizard which you can find here at codeguru and take a look how the generated programs does it.

Greetings,
Jean-Marie

bimmer boy
June 25th, 1999, 07:35 AM
are you running this code as an administrator? you have the constant SERVICE_ALL_ACCESS in there...i'm not sure, but i do believe that this is allowed only for administrators.

also, are you calling OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE) first to tell it you want to create a service?

that's all i know.


miked