CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: NT Services

  1. #1
    Guest

    NT Services

    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.


  2. #2
    Join Date
    Jun 1999
    Posts
    27

    Re: NT Services

    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


  3. #3
    Join Date
    Jun 1999
    Posts
    315

    Re: NT Services

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured