ENUM_SERVICE_STATUS EnService[512]; SC_HANDLE ScManager,ScService; //Handle of service manager DWORD cbBufSize=512*sizeof(ENUM_SERVICE_STATUS); DWORD lpServicesReturned; DWORD pcbBytesNeeded; DWORD lpResumeHandle=0; //For querying service info DWORD dwBytesNeeded; //LPQUERY_SERVICE_CONFIG lpqscBuf; //Open the service manager with all as desired access ScManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); char szStatus[255]; char szStartType[255]; if(ScManager==NULL) { printf("Error querying the service manager"); return 0; } if(::EnumServicesStatus( ScManager,//Service manager Handle SERVICE_WIN32, //Service type To be retrieved SERVICE_STATE_ALL, //Retrive all windows services EnService, //Our buffer cbBufSize, //Buffer size &pcbBytesNeeded, //number of bytes needed &lpServicesReturned, //number of services returned &lpResumeHandle //Resume handle (if any) )==0){ printf("Error querying the service manager"); return 0; } if((ScService=::OpenService(ScManager,_T("MYSQL"),SERVICE_ALL_ACCESS))==NULL) { printf("Error opening service"); } //Allocate some memory in our buffer for the actual querying /*lpqscBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, 4096); if (lpqscBuf == NULL) { printf("Error allocating service query"); sprintf(szStartType,"Unknown"); } //Retrieve the configuration info if (! QueryServiceConfig( ScService, lpqscBuf, 4096, &dwBytesNeeded) ) { printf("Error querying service info"); sprintf(szStartType,"Unknown"); }*/
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)