CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Nov 2004
    Posts
    54

    Can't my service running in the list of services

    Hello everybody,
    I have developed a service following an article from CodeGuru. I see it runs because I can debug it, but I cannot see it from the list of services on my machine.
    Does anyone have any idea of the reason? I'm on a Windows 2000 machine.

    Thank you all,
    Annalisa Bacherotti

  2. #2
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    It is a good idea that when you reference an article that you provide a link to the article. Some of the articles and the ATL wizard for services allow for your code to run without calling the Service API's to install the service. If you did create an ATL wizard app service project then you need to pass -servcie or /service to create the service.

  3. #3
    Join Date
    Jun 2003
    Location
    Bucharest, Romania
    Posts
    529

    Re: Can't my service running in the list of services

    Quote Originally Posted by annalisa1976
    Hello everybody,
    I have developed a service following an article from CodeGuru. I see it runs because I can debug it, but I cannot see it from the list of services on my machine.
    Does anyone have any idea of the reason? I'm on a Windows 2000 machine.

    Thank you all,
    Annalisa Bacherotti
    in the end a service is just an app. If you don't install it the system won't "see" it!
    Help me help you ... rate this article if any good!

  4. #4
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    ok you're right.
    The article is the following
    http://www.codeguru.com/Cpp/W-P/syst...php/c2809/#MFC
    and is titled
    A Class For Building An NT Service.

    I'have specified the option

    -d -i

    in Program arguments from Project/Settings, tab Debug, General option, as suggested. I thought it was enough.. Icreated a console program..
    What else should I do? It's the first time I do it, I'm quite confused..

  5. #5
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    Did you call the RegisterService(...) member function? You should probably step into the code under a debugger or zip up your source/headers and post what you have done.

    Look at the sample project download from the link.

  6. #6
    Join Date
    Feb 2002
    Location
    Krispl, Austria
    Posts
    197

    Re: Can't my service running in the list of services

    If it's not in the list of services then it's not installed. Debugging it using the IDE is not running the code "as a service". The service must be registered using the -i option as discussed in the article. You must have missed something somewhere.

    Try debuggin it and using the -i option and
    1 - Ensure it executes the registration code.
    2 - There are no errors returned during registration.
    Requests such as
    "I need to write an new language compiler by next week, I have teach yourself c++ in 21 days, can someone give me example code?" will be ignored.

  7. #7
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    Well, guys, another problem occurred now. I hope you will be so kind to keep pn helping me..
    When I was trying to debug the app, and simply called the constructor in main.cpp,
    the application threw an assert!
    So I can't even try to register anymore. I think the assert is thrown because there's more than one instance of the app..

    Code:
    //my file
    #ifdef _CONSOLE
    int main( int argc, char ** argv )
    {
    #else
    	int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {
    	int argc = __argc;
    	char ** argv = __argv;
    #endif	// _CONSOLE
    
    	// create the service-object
    	CIService serv; //HERE STARTS THE ASSERT!!!!!!!!!!
    
    	return serv.RegisterService(argc, argv);
    }
    Code:
    //NTService.h
    //HERE THE ASSERT IS THROWN
    
    _ASSERTE( ! m_bInstance );
    Do you know a way to discover it? I know it's difficult witout the code, but I can't send it. It doesn't work without some APIs for image recognition. I will try to semplify it at most as I can..
    Thank you very very much everybody

  8. #8
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    Just some clarification.

    You can debug a service within the IDE. This is generally a two step process, the first as pointed out is to debug during the creation of the service: CreateService(...) etc.

    The second is to debug during the invokation of the service by the SCM. To debug using the IDE use attach to process. There is an issue with < sp6 where services will not be listed in the process task. To get around this pass the service pid to msdev [-p/-e] from the command line or use windbg from msdn.microsoft.com.

    If you are debugging the actual startup code then you must be aware that the SCM must be updated periodically with SetServiceStatus(...) or the SCM will time you out.

    Service Documentation

    Link to various techniques to debug services using windbg [which can be replaced with msdev]

    http://support.microsoft.com/default...b;en-us;824344

  9. #9
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    Quote Originally Posted by annalisa1976
    Well, guys, another problem occurred now. I hope you will be so kind to keep pn helping me..
    When I was trying to debug the app, and simply called the constructor in main.cpp,
    the application threw an assert!
    So I can't even try to register anymore. I think the assert is thrown because there's more than one instance of the app..

    m_bInstance is static you have more than one instance in your application.

  10. #10
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    Thank you all.. I think I have to read more docs. meanwhile, I'll try to build a simplified version of my project, so that I can send it attached if needed.

    Regards,
    Annalisa

  11. #11
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    ok, I have written a service from my app that doesn't do anything except sending a message once when it executes. But it gives an assert just at the beginnig.
    Anyone can help me?
    The problem is born this morning, not before..

    Thank you
    Attached Files Attached Files

  12. #12
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    First instance:

    Code:
    struct tagGlobal
    {
      CIServ  m_ser;
    } GlobalData;
    Second instance:
    Code:
    main()
    {
    CIServ serv;
    }

  13. #13
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    You're right.That has fixed the problem about crashing..
    Sorry if my mistake has bothered you so much.
    Thank you, guys, you've been very kind. Now I'm gonna try to see the name of the service in the service list.
    Regards,
    Annalisa

  14. #14
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Can't my service running in the list of services

    Quote Originally Posted by annalisa1976
    You're right.That has fixed the problem about crashing..
    Sorry if my mistake has bothered you so much.
    Thank you, guys, you've been very kind. Now I'm gonna try to see the name of the service in the service list.
    Regards,
    Annalisa
    No problem. Your are not "bothering" us

  15. #15
    Join Date
    Nov 2004
    Posts
    54

    Re: Can't my service running in the list of services

    The fact that I'm developing a service on Windows 2000 and not on NT and I'm following the article
    http://www.codeguru.com/Cpp/W-P/syst...php/c2809/#MFC
    referring to an NT service could be a problem?

    Annalisa

Page 1 of 2 12 LastLast

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