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. Create And Start Service using C++

Create And Start Service using C++

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
5 Posts 2 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.
  • S Offline
    S Offline
    sangamdumne
    wrote on last edited by
    #1

    Hi friends, I'm trying to create My own service for .exe. my service create function successfully creates service but when i try to start to that service then it gives error code 1053 which is ERROR_SERVICE_REQUEST_TIMEOUT. also i saw that startservice() fun goes in waiting for 30seconds and then gives error 1053. pls help, here is my code for ur ref... hServiceMGROpen=OpenSCManager(serverName,SERVICES_ACTIVE_DATABASE,SC_MANAGER_ALL_ACCESS); if(hServiceMGROpen!=NULL) { hServiceOpen=OpenService(hServiceMGROpen,"myService",SERVICE_ALL_ACCESS); if(hServiceOpen!=NULL) { succStart=StartService(hServiceOpen,0,NULL); if(succStart) { printf("Service starts successfully "); } else { DWORD err=GetLastError(); printf("Error %d",err); } } }

    Thanks in advance...!!! Sangam

    J 1 Reply Last reply
    0
    • S sangamdumne

      Hi friends, I'm trying to create My own service for .exe. my service create function successfully creates service but when i try to start to that service then it gives error code 1053 which is ERROR_SERVICE_REQUEST_TIMEOUT. also i saw that startservice() fun goes in waiting for 30seconds and then gives error 1053. pls help, here is my code for ur ref... hServiceMGROpen=OpenSCManager(serverName,SERVICES_ACTIVE_DATABASE,SC_MANAGER_ALL_ACCESS); if(hServiceMGROpen!=NULL) { hServiceOpen=OpenService(hServiceMGROpen,"myService",SERVICE_ALL_ACCESS); if(hServiceOpen!=NULL) { succStart=StartService(hServiceOpen,0,NULL); if(succStart) { printf("Service starts successfully "); } else { DWORD err=GetLastError(); printf("Error %d",err); } } }

      Thanks in advance...!!! Sangam

      J Offline
      J Offline
      JohnCz
      wrote on last edited by
      #2

      What does it mean: here is my code for ur ref... Anyway, ERROR_SERVICE_REQUEST_TIMEOUT, means that your ServiceControlHandler (or whatever name you have used to register handler callback) is not responding fast enough to the setvice start request, blocking StartServiceCtrlDispatcher. Or you did not call StartServiceCtrlDispatcher at all. If you have to perform some lenghty procedure when the service starts, do it in the thread, or after setting service start status.

      JohnCz

      S 1 Reply Last reply
      0
      • J JohnCz

        What does it mean: here is my code for ur ref... Anyway, ERROR_SERVICE_REQUEST_TIMEOUT, means that your ServiceControlHandler (or whatever name you have used to register handler callback) is not responding fast enough to the setvice start request, blocking StartServiceCtrlDispatcher. Or you did not call StartServiceCtrlDispatcher at all. If you have to perform some lenghty procedure when the service starts, do it in the thread, or after setting service start status.

        JohnCz

        S Offline
        S Offline
        sangamdumne
        wrote on last edited by
        #3

        here is my code for ur ref means i'm trying to show you that what i have done :laugh:

        J 1 Reply Last reply
        0
        • S sangamdumne

          here is my code for ur ref means i'm trying to show you that what i have done :laugh:

          J Offline
          J Offline
          JohnCz
          wrote on last edited by
          #4

          Hi, Where is your code? Another thing: Could you lease refrain from using cryptic code like "ur ref means"? I would really appreciate it, since to understand it I need translation to English.

          JohnCz

          S 1 Reply Last reply
          0
          • J JohnCz

            Hi, Where is your code? Another thing: Could you lease refrain from using cryptic code like "ur ref means"? I would really appreciate it, since to understand it I need translation to English.

            JohnCz

            S Offline
            S Offline
            sangamdumne
            wrote on last edited by
            #5

            hServiceMGROpen=OpenSCManager(serverName,SERVICES_ACTIVE_DATABASE,SC_MANAGER_ALL_ACCESS); if(hServiceMGROpen!=NULL) { hServiceOpen=OpenService(hServiceMGROpen,"myService",SERVICE_ALL_ACCESS); if(hServiceOpen!=NULL) { succStart=StartService(hServiceOpen,0,NULL); if(succStart) { printf("Service starts successfully "); } else { DWORD err=GetLastError(); printf("Error %d",err); } } } this is my code....!!!! please findout problem....

            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