Use the service API:
Code:#include <Winsvc.h> //... SC_HANDLE hsv,hmc; SERVICE_STATUS sst; hsv=OpenSCManager(NULL,0,SC_MANAGER_CONNECT); hmc=OpenService(hsv,L"MyService",GENERIC_READ); if(hmc==NULL){ //service not installed; handle error } QueryServiceStatus(hmc,&sst); if(SERVICE_RUNNING!=sst.dwCurrentState){ //wait or do whatever until it starts } CloseServiceHandle(hmc); CloseServiceHandle(hsv);




Reply With Quote