CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    171

    Proper way to exit my service

    What is the best way to exit my service? I want to stop my service on a few occasions if i encounter serious errors that will not allow me to proceed.


    SHould I just set the state like:

    Code:
    g_ServiceStatus.dwCurrentState       = SERVICE_STOPPED;
    and then return from ServiceMain()???


    If i do this, then a messagebox pops up saying that the service started and then stopped.

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    Check out DeleteService().

    Kuphryn

  3. #3
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    171
    I don't want to delete the service, I just want to exit it.

  4. #4
    Join Date
    Jan 2002
    Location
    TamilNadu, India
    Posts
    158
    The following may be useful.

    In case you encounter errors..
    • You might want to close all the waiting threads
    • Set the service status to service stop pending
    • do any other cleanup
    • then return


    Hope this is what u r looking for..

    If not state the exact problem with ur error instance & sample code..
    Muthu

  5. #5
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by muthuis
    The following may be useful.

    In case you encounter errors..
    • You might want to close all the waiting threads
    • Set the service status to service stop pending
    • do any other cleanup
    • then return


    Hope this is what u r looking for..

    If not state the exact problem with ur error instance & sample code..
    add:
    Set the ServiceStatus(...) to stopped before the return from ServiceMain(...), otherwise the SC manager should still believe a stop is pending and denote that with a timeout message.

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