ControlService on Vista
I install a service using the default username and password as so:
SC_HANDLE service = CreateService(serviceControlManager,
SVC_NAME, SVC_NAME,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, path,
NULL, NULL, NULL, NULL, NULL);
And that's all fine and dandy.
Then I try to send the service some messages, via a separate
application using ControlService. I have elevated the privileges for
this application to requireAdministrator using an XML manifest file.
When executed, I must either 'runas' an administrator, or confirm the
elevated privileges. For an unknown reason, the commands are not
being received on Vista. From my testing, it appears that XP has no
problem sending these messages to my service.
This is how I send messages to the Service.
UINT TellServer(UINT iMsg) {
SC_HANDLE schSCManager = OpenSCManager(NULL, NULL,
SC_MANAGER_ALL_ACCESS);
SERVICE_STATUS ssStatus;
if (schSCManager) {
SC_HANDLE schService = OpenService(schSCManager, SVC_NAME,
SERVICE_ALL_ACCESS);
if (schService) {
if (ControlService(schService, iMsg, &ssStatus)) {
return 1;
}
}
CloseServiceHandle(schService);
}
CloseServiceHandle(schSCManager);
return 0;
}
On Vista, OpenService is returning NULL and failing to continue on to
ControlService.
Are there any prerequisites I'm missing to successfully send messages
to a service in Vista? Any information would be greatly appreciated.