#1 2016-04-05 08:24:27

Eric
Member
Registered: 2012-11-26
Posts: 129
Website

ServiceController & TServiceState

When TServiceController.CreateOpenService succeeds at opening the SC Manager, but fails at OpenService, it ends up in a state with FSCHandle <> 0 and FHandle = 0

However TServiceController.GetState then proceeds to report that as ssNotInstalled, when it should be ssErrorRetrievingState, or some more detailed information should be preserved.

https://msdn.microsoft.com/en-us/librar … s.85).aspx

Lists the cases when OpenService can return a null handle, among which ERROR_ACCESS_DENIED and ERROR_INVALID_NAME do not correspond to a service not installed.

Offline

#2 2016-04-05 12:14:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: ServiceController & TServiceState

Offline

#3 2016-04-06 06:42:47

Eric
Member
Registered: 2012-11-26
Posts: 129
Website

Re: ServiceController & TServiceState

This improves things for insufficient rights, but seemed to fail reporting when the service really was not installed.

I have gone the extra mile here by introducing a TServiceStateEx with an ssAccessDenied element, and checking the GetLastError after calling CreateOpenService.

Offline

Board footer

Powered by FluxBB