如何从注册表中得知服务的状态

13a*_*aal 4 windows-registry windows-7 services

举例来说,我想从注册表中找出我的蓝牙服务处于什么状态:

  1. 我会使用打开注册表regedit
  2. 找到路径:SYSTEM\CurrentControlSet\Services\BTHPORT

我如何判断蓝牙服务是手动、禁用还是启用?

Ƭᴇc*_*007 7

通过注册表,您将无法知道服务当前处于什么状态,只能知道它的启动模式设置(手动、自动、禁用等)。这将保存在注册表中服务分支内名为“Start”的键中。

可能的值:

+-------+----------------------------------------------------------------------------------------------------------------------------------+
| Value |                                                           Description                                                            |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
|     0 | Boot: Loaded by kernel loader. Components of the driver stack for the boot (startup) volume must be loaded by the kernel loader. |
|     1 | System: Loaded by I/O subsystem. Specifies that the driver is loaded at kernel initialization.                                   |
|     2 | Automatic: Loaded by Service Control Manager. Specifies that the service is loaded or started automatically.                     |
|     3 | Manual: The service does not start until the user starts it manually, such as by using Services or Devices in Control Panel.     |
|     4 | Disabled: Specifies that the service should not be started.                                                                      |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)

如果您希望获取服务的当前状态,请考虑使用sc命令WMI