service status
-
Hi, i am looking for some api, or method to check the current status of a service and return a value to a program, then if needs be i can start the service via net start or relevant method Thanks
I am not sure about your specific problem, but you may try using something like this to find your service:
SC_HANDLE hM = OpenSCManager(NULL,NULL,SC_MANAGER_ENUMERATE_SERVICE); if (hM) { ENUM_SERVICE_STATUS stat[1024]; DWORD dwNeeded; DWORD dwRet; DWORD dwFirst = 0; if (EnumServicesStatus(hM,SERVICE_WIN32|SERVICE_DRIVER,SERVICE_STATE_ALL,stat,sizeof(stat),&dwNeeded,&dwRet,&dwFirst)) { for (DWORD n=0;n Or, if you are already in posession of the service handle, `BOOL QueryServiceStatus( SC_HANDLE hService, // handle to service LPSERVICE_STATUS lpServiceStatus // service status );` Enjoy! Maksim Lepikhin [www.softforpros.com](http://www.softforpros.com)
-
Hi, i am looking for some api, or method to check the current status of a service and return a value to a program, then if needs be i can start the service via net start or relevant method Thanks