Environment: VC6, Win2000 SP2
This dialog-based VC++ application can be used to control the services in WinNT/2000. To install, follow these steps and the following code:
- Open the service control manager and get the handle.
- Create the service and get the service handle.
- Close the handles.
SC_HANDLE hSCMD = OpenSCManager(NULL,NULL,
SC_MANAGER_CREATE_SERVICE);
SC_HANDLE hService = NULL;
if (g_szAcntName[0] == 0)
{
hService = CreateService(hSCMD, g_szServName, g_szServName, NULL,
SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, szBinaryPath, NULL,NULL, NULL,
NULL, NULL);
}
else{
hService = CreateService(hSCMD, g_szServName, g_szServName, NULL,
SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL, szBinaryPath, NULL,NULL,
NULL, g_szAcntName, g_szPassword);
}
CloseServiceHandle(hService);
CloseServiceHandle(hSCMD);To uninstall, follow these steps and the following code:
- Open the service control manager and get the handle.
- Open the service and get the service handle.
- Delete the service by giving the service handle.
- Close the handles.
SC_HANDLE hSCMD = OpenSCManager(NULL,NULL, SC_MANAGER_CREATE_SERVICE); SC_HANDLE hService = OpenService(hSCMD,g_szServName, DELETE); DeleteService(hService); CloseServiceHandle(hService); CloseServiceHandle(hSCMD);Downloads