Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. NT Service problem

NT Service problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yamini
    wrote on last edited by
    #1

    Hi All, I have a NT Service.I want to shut down the service without the interpretation of SCM.So, I calling CServiceModule::Handler() with opcode "SERVICE_CONTROL_STOP" and the service to shutdown.But, my service is shutting down at the same time it's giving error "Error :2140 An Internal error occured" . How can I rectify the problem.I would like to know what happens after I say service shutdown. Thanx in advance for the help. Regards, yamini

    M C 2 Replies Last reply
    0
    • Y yamini

      Hi All, I have a NT Service.I want to shut down the service without the interpretation of SCM.So, I calling CServiceModule::Handler() with opcode "SERVICE_CONTROL_STOP" and the service to shutdown.But, my service is shutting down at the same time it's giving error "Error :2140 An Internal error occured" . How can I rectify the problem.I would like to know what happens after I say service shutdown. Thanx in advance for the help. Regards, yamini

      M Offline
      M Offline
      Martin Ziacek
      wrote on last edited by
      #2

      Try this: http://support.microsoft.com/support/kb/articles/Q115/8/29.asp Kind regards, Martin

      Y 1 Reply Last reply
      0
      • M Martin Ziacek

        Try this: http://support.microsoft.com/support/kb/articles/Q115/8/29.asp Kind regards, Martin

        Y Offline
        Y Offline
        yamini
        wrote on last edited by
        #3

        Hi, Thanx for the idea.But, I am using ATL Service.I ahve a function CServiceModule::ServiceShutDown() & the function code goes as below. void CServieModule::ServiceShutDown() { SetServiceStatus(SERVICE_STOPPED); PostQuitMessage(dwThreadID,WM_QUIT,0,0); } I am calling this function from CServiceModule::Run() before the Loop and I put a MessageBox in CServiceModule::Handler() case SERVICE_CONTROL_STOP to indicate that the service is stopped.When I try to start the service thro' SCM I am getting MessageBox and also error that "Error :2140 An internal Error occured>". How can I update the SCM UI and notify that the Service has terminated(When the service terminates instead of Error I need to notify that Service cannot be started ).I mean, how can I terminate the service without such errors as I am using ATL generated Code & I want to achieve the service termination with this ATL Generated Code only. Thanx.

        M 1 Reply Last reply
        0
        • Y yamini

          Hi, Thanx for the idea.But, I am using ATL Service.I ahve a function CServiceModule::ServiceShutDown() & the function code goes as below. void CServieModule::ServiceShutDown() { SetServiceStatus(SERVICE_STOPPED); PostQuitMessage(dwThreadID,WM_QUIT,0,0); } I am calling this function from CServiceModule::Run() before the Loop and I put a MessageBox in CServiceModule::Handler() case SERVICE_CONTROL_STOP to indicate that the service is stopped.When I try to start the service thro' SCM I am getting MessageBox and also error that "Error :2140 An internal Error occured>". How can I update the SCM UI and notify that the Service has terminated(When the service terminates instead of Error I need to notify that Service cannot be started ).I mean, how can I terminate the service without such errors as I am using ATL generated Code & I want to achieve the service termination with this ATL Generated Code only. Thanx.

          M Offline
          M Offline
          Martin Ziacek
          wrote on last edited by
          #4

          SCM shows error 2140 in a case, when your service terminates with 'process return value' equal to 0. You have to find a way, how to return proper value (!= 0) when service process terminates. However, I cannot help you with ATL service class, because I have never used it - sorry.

          1 Reply Last reply
          0
          • Y yamini

            Hi All, I have a NT Service.I want to shut down the service without the interpretation of SCM.So, I calling CServiceModule::Handler() with opcode "SERVICE_CONTROL_STOP" and the service to shutdown.But, my service is shutting down at the same time it's giving error "Error :2140 An Internal error occured" . How can I rectify the problem.I would like to know what happens after I say service shutdown. Thanx in advance for the help. Regards, yamini

            C Offline
            C Offline
            Carlos Antollini
            wrote on last edited by
            #5

            I had the same problem. I made this. I saw that the problem was that the service didn't stop normally. You have a thread that is dowing the service but the service didn't know that. I put saome global variables for that. For example when I recive the SEVICE_CONTROL_STOP I update a variable like bRuning = FALSE; In the Run I always Ask about this variable, I if I find that this variable is FALSE, I go out. (Kill all process like threads, etc, and go out from Run.) Sometimes the problem is an error in the code that you in debug mode don't see. I work with trace file and with the Event log for test my Release version. Sometimes I have a mistake. I hope to Help!!!! ;) ;) ;) ;) Regards:-D Carlos Antollini.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups