OpenSCManager The OpenSCManager function establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
VB4-32,5,6
Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) As Long |
Operating Systems Supported |
Requires Windows NT 3.1 or later; Win9x/ME: Not supported |
- lpMachineName
[in] Pointer to a null-terminated string that specifies the name of the target computer. The target computer name must be prefixed by "\\". 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] Specifies the access to the service control manager. Before granting the requested access, 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 type is implicitly specified by calling this function. In addition, any or all of the following service control manager object access types can be specified.
SC_MANAGER_ALL_ACCESS
Includes STANDARD_RIGHTS_REQUIRED, in addition to all of the access types listed in this table.
SC_MANAGER_CONNECT
Enables connecting to the service control manager.
SC_MANAGER_CREATE_SERVICE
Enables calling of the CreateService function to create a service object and add it to the database.
SC_MANAGER_ENUMERATE_SERVICE
Enables calling of the EnumServicesStatus function to list the services that are in the database.
SC_MANAGER_LOCK
Enables calling of the LockServiceDatabase function to acquire a lock on the database.
SC_MANAGER_QUERY_LOCK_STATUS
Enables calling of the QueryServiceLockStatus function to retrieve the lock status information for the database.
The dwDesiredAccess parameter can specify any or all of the following generic access types.
GENERIC_READ
Combines the following access types: STANDARD_RIGHTS_READ, SC_MANAGER_ENUMERATE_SERVICE, and SC_MANAGER_QUERY_LOCK_STATUS.
GENERIC_WRITE
Combines the following access types: STANDARD_RIGHTS_WRITE and SC_MANAGER_CREATE_SERVICE.
GENERIC_EXECUTE
Combines the following access types: STANDARD_RIGHTS_EXECUTE, SC_MANAGER_CONNECT, and SC_MANAGER_LOCK. |
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. |
|