Opening an SCManager Database
Many operations require an open handle to an SCManager object. The following example demonstrates how to obtain the handle.
Different operations on the SCM database require different levels of access, and you should only request the minimum access required. If SC_MANAGER_ALL_ACCESS is requested, the OpenSCManager function fails if the calling process does not have Administrator privileges. The following example shows how to request full access to the ServicesActive database on the local computer.
#include <windows.h>
#include <stdio.h>
SC_HANDLE schSCManager;
// Open a handle to the SC Manager database.
schSCManager = OpenSCManager(
NULL, // local machine
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights
if (NULL == schSCManager)
printf("OpenSCManager failed (%d)/n", GetLastError());
打开SCManager数据库示例
博客介绍了打开SCManager数据库的相关内容。许多操作需要一个打开的SCManager对象句柄,文中给出获取句柄示例。同时指出SCM数据库不同操作需不同访问级别,应请求最小访问权限,还给出请求本地计算机ServicesActive数据库完全访问权限的示例。
3258

被折叠的 条评论
为什么被折叠?



