System.ServiceProcess 命名空间

提供允许你实现、安装和控制 Windows 服务应用程序的类。 Provides classes that allow you to implement, install, and control Windows service applications. 服务是长期运行的可执行文件,它们不通过用户界面来运行。 Services are long-running executables that run without a user interface. 实现服务涉及以下方面:从 ServiceBase 类继承,定义在传入开始、停止、暂停和继续命令时要处理的特定行为,以及定义在系统关闭时要执行的自定义行为和操作。 Implementing a service involves inheriting from the ServiceBase class and defining specific behavior to process when start, stop, pause, and continue commands are passed in, as well as custom behavior and actions to take when the system shuts down.


为将作为服务应用程序的一部分而存在的服务提供基类。Provides a base class for a service that will exist as part of a service application. 在创建新的服务类时,必须从 ServiceBase 派生。ServiceBase must be derived from when creating a new service class.


表示 Windows 服务并允许连接到正在运行或者已停止的服务、对其进行操作或获取有关它的信息。Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it.


允许服务控制器对代码访问安全权限的控制。Allows control of code access security permissions for service controllers.


允许声明性的服务控制器权限检查。Allows declarative service controller permission checks.


定义为 ServiceController 设置的代码访问安全性权限的最小单位。Defines the smallest unit of a code access security permission that is set for a ServiceController.


包含 ServiceControllerPermissionEntry 对象的强类型集合。Contains a strongly-typed collection of ServiceControllerPermissionEntry objects.


安装一个类,该类扩展 ServiceBase 来实现服务。Installs a class that extends ServiceBase to implement a service. 在安装服务应用程序时由安装实用工具调用该类。This class is called by the install utility when installing a service application.


指定属性或事件的说明。Specifies a description for a property or event.


安装一个可执行文件,该文件包含扩展 ServiceBase 的类。Installs an executable containing classes that extend ServiceBase. 该类由安装实用工具(如 InstallUtil.exe)在安装服务应用程序时调用。This class is called by installation utilities, such as InstallUtil.exe, when installing a service application.


当指定的超时时间已过时引发的异常。The exception that is thrown when a specified timeout has expired.



确认终端服务会话更改的原因。Identifies the reason for a Terminal Services session change.



指示系统的电源状态。Indicates the system's power status.


指定服务的安全上下文,安全上下文定义其登录类型。Specifies a service's security context, which defines its logon type.


定义 ServiceController 权限类使用的访问级别。Defines access levels used by ServiceController permission classes.


指示服务的当前状态。Indicates the current state of the service.


指示服务的启动模式。Indicates the start mode of the service.


表示服务的类型。Represents the type of the service.


指定终端服务会话更改通知的原因。Specifies the reason for a Terminal Services session change notice.


使用安装实用程序(如 InstallUtil.exe)安装服务。Services are installed using an installation utility such as InstallUtil.exe. System.ServiceProcess命名空间提供将服务信息写入注册表的安装类。The System.ServiceProcess namespace provides installation classes that write service information to the registry. ServiceProcessInstaller类提供一个包含类,用于安装安装中的所有服务所共有的组件。The ServiceProcessInstaller class provides an encompassing class which installs components common to all the services in an installation. 对于每个服务,可以创建类的实例 ServiceInstaller 以安装特定于服务的功能。For each service, you create an instance of the ServiceInstaller class to install service-specific functionality.

ServiceController类使你可以连接到现有服务并对其进行操作或获取有关它的信息。The ServiceController class enables you to connect to an existing service and manipulate it or get information about it. 此类通常用于管理容量,并使你能够在服务上启动、停止、暂停、继续或执行自定义命令。This class is typically used in an administrative capacity, and enables you to start, stop, pause, continue, or perform custom commands on a service. ServiceBase如果类定义了命令发生时服务所执行的处理,则 ServiceController 是允许您在服务上调用这些命令的代理。Where the ServiceBase class defines the processing a service performs when a command occurs, the ServiceController is the agent that enables you to call those commands on the service.