OpenSCManager
From Ggl's wiki
Contents |
Description
Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
Prototype
SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR lpDatabaseName, DWORD dwDesiredAccess );
Parameters
- lpMachineName
- [in] Pointer to a null-terminated string that specifies the name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.
- lpDatabaseName
- [in] Pointer to a null-terminated string that specifies the name of the service control manager database to open. This parameter should be set to SERVICES_ACTIVE_DATABASE. If it is NULL, the SERVICES_ACTIVE_DATABASE database is opened by default.
- dwDesiredAccess
- [in] Access to the service control manager. For a list of access rights, see Service Security and Access Rights.
Before granting the requested access rights, the system checks the access token of the calling process against the discretionary access-control list of the security descriptor associated with the service control manager.
The SC_MANAGER_CONNECT access right is implicitly specified by calling this function.
Return Value
- If the function succeeds
- the return value is a handle to the specified service control manager database.
- If the function fails
- the return value is NULL. To get extended error information, call GetLastError.
The following error codes can be set by the SCM. Other error codes can be set by the registry functions that are called by the SCM.
- ERROR_ACCESS_DENIED
- The requested access was denied.
- ERROR_DATABASE_DOES_NOT_EXIST
- The specified database does not exist.
- ERROR_INVALID_PARAMETER
- A specified parameter is invalid.

