In case OpenSCMnager returns ERROR_ACCESS_DENIED(0x5) it will be successfully casted to integer and check_services_creation_with_openscmanager() will return True.
def check_services_creation_with_openscmanager():
isPossible = False
try:
# open the SCM with "SC_MANAGER_CREATE_SERVICE" rights
createServ = OpenSCManager(None, None, SC_MANAGER_CREATE_SERVICE)
try:
if int(createServ) != 0:
return True
# if the int cast failed (when it is an HANDLE)
except:
return True
except:
pass
return False
In case OpenSCMnager returns ERROR_ACCESS_DENIED(0x5) it will be successfully casted to integer and check_services_creation_with_openscmanager() will return True.