Create And Start Service using C++
-
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
-
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
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
-
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
here is my code for ur ref means i'm trying to show you that what i have done :laugh:
-
here is my code for ur ref means i'm trying to show you that what i have done :laugh:
-
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
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....