The HKLM\SYSTEM\CurrentControlSet\Services registry tree stores information about each service on the system. Each driver has a key of the form HKLM\SYSTEM\CurrentControlSet\Services\DriverName.
The PnP manager passes this path of a driver in the RegistryPath parameter when it calls the driver's DriverEntry routine. A driver can store global driver-defined data under the Parameters subkey of its key in the Services tree using an AddReg directive in the driver's INF file. To access that key at runtime, a WDM driver should use IoOpenDriverRegistryKey with a DRIVER_REGKEY_TYPE of DriverRegKeyParameters and a WDF driver should use WdfDriverOpenParametersRegistryKey. 此密钥下存储的信息在初始化期间可供驱动程序使用。
有关驱动程序通常使用的注册表项的详细信息,请参阅 驱动程序的注册表项简介。
HKLM\SYSTEM\CurrentControlSet\Services 中的其他密钥
Parameters
用于存储驱动程序特定数据的密钥。 对于某些类型的驱动程序,系统需要查找特定的值条目。 You can add value entries to this subkey using AddReg directives in the driver's INF file.
Performance
一个键,指定可选性能监视的信息。 此键下的值指定驱动程序性能 DLL 的名称以及该 DLL 中某些导出函数的名称。 You can add value entries to this subkey using AddReg directives in the driver's INF file.
HKLM\SYSTEM\CurrentControlSet\Services<DriverName 中的常见注册表项和值>
Start
该值 Start 指定何时应启动服务。 它可以具有以下值之一:
-
0x0(启动):由启动加载程序加载。 -
0x1(系统):由 I/O 子系统加载。 -
0x2(自动):在系统启动期间由服务控制管理器自动加载。 -
0x3(需求):如果需要设备,则由 PnP 自动加载。 -
0x4(已禁用):服务已禁用,不会加载。
类型
该值 Type 指定服务的类型。 它可以是以下值的组合:
-
0x1(内核驱动程序):设备驱动程序。 -
0x2(文件系统驱动程序):文件系统驱动程序。 -
0x10(Win32 自己的进程):一个在其自己的进程中运行的 Win32 程序。 -
0x20(Win32 共享进程):与其他服务共享进程的 Win32 计划。
ErrorControl
如果服务无法启动,则 ErrorControl 该值指定错误的严重性。 它可以具有以下值之一:
-
0x0(忽略):将忽略错误,并且启动会继续。 -
0x1(正常):记录错误,可能会显示消息框,但启动会继续。 -
0x2(严重):记录错误,系统使用最后一个已知良好的配置重新启动。 -
0x3(严重):记录错误,系统尝试使用最后一个已知良好的配置重启。 如果此作失败,启动将失败,系统将停止。
其他通用值
-
ImagePath:指定服务二进制文件的路径。 Windows creates this value by using the required ServiceBinary entry in the driver's INF file. This entry is in the service-install-section referenced by the driver's INF AddService directive. -
DisplayName:服务的友好名称。 -
Description:服务的说明。
Example
下面是服务的注册表项示例:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ExampleService]
"Start"=dword:00000002
"Type"=dword:00000010
"ErrorControl"=dword:00000001
"ImagePath"="C:\\Program Files\\ExampleService\\example.exe"
"DisplayName"="Example Service"
"Description"="This is an example service."