Opens an existing service.
OpenService(cServiceName [, nAccess [, cServer [, cDatabase]]])
Parameters
- cServiceName | nServiceHandle
Either the name of the service or a numeric handle returned from the OpenService function.
- nAccess (optional, additiive)
default = SERVICE_ALL_ACCESS
The desired access to the service.
One or a combination of the following values. Access right Description SERVICE_ALL_ACCESS Includes STANDARD_RIGHTS_REQUIRED in addition to all access rights in this table. SERVICE_CHANGE_CONFIG Required to call the ChangeServiceConfig or ChangeServiceConfig2 function to change the service configuration. Because this grants the caller the right to change the executable file that the system runs, it should be granted only to administrators. SERVICE_ENUMERATE_DEPENDENTS Required to call the ADependentServices function to enumerate all the services dependent on the service. SERVICE_INTERROGATE Required to call the ControlService function to ask the service to report its status immediately. SERVICE_PAUSE_CONTINUE Required to call the PauseService and ContinueService functions. SERVICE_QUERY_CONFIG Required to call the AServiceConfig function to query the service configuration. SERVICE_QUERY_STATUS Required to call the AServiceStatus function to ask the service control manager about the status of the service. SERVICE_START Required to call the StartService function to start the service. SERVICE_STOP Required to call the ControlService function to stop the service. SERVICE_USER_DEFINED_CONTROL Required to call the ControlService function to specify a user-defined control code.
- cServer (optional)
The server name on which the service is running.
See MSDN help for OpenSCManager.
- cDatabase (optional)
The database under which the service is registered.
See MSDN help for OpenSCManager.
Return Value
A handle for the windows service.
See Also
Reference
ADependentServices
AServiceConfig
AServices
AServiceStatus
CloseServiceHandle
ContinueService
ControlService
CreateService
PauseService
StartService
StopService
WaitForServiceStatus