System.ServiceProcess 命名空間

System.ServiceProcess 命名空間提供可以讓您實作、安裝和控制 Windows 服務應用程式的類別。 The System.ServiceProcess namespace 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.

類別

ServiceBase

提供將會屬於服務應用程之服務的基底類別。Provides a base class for a service that will exist as part of a service application. 當建立新的服務類別時,必須衍生自 ServiceBaseServiceBase must be derived from when creating a new service class.

ServiceController

表示 Windows 服務,可以讓您連接到執行中或已停止的服務進行管理,或取得關於服務的資訊。Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it.

ServiceControllerPermission

允許服務控制器的程式碼存取安全性權限的控制。Allows control of code access security permissions for service controllers.

ServiceControllerPermissionAttribute

允許宣告式服務控制器使用權限檢查。Allows declarative service controller permission checks.

ServiceControllerPermissionEntry

定義設定給 ServiceController 之程式碼存取安全性權限的最小單位。Defines the smallest unit of a code access security permission that is set for a ServiceController.

ServiceControllerPermissionEntryCollection

包含 ServiceControllerPermissionEntry 物件的強型別集合。Contains a strongly-typed collection of ServiceControllerPermissionEntry objects.

ServiceInstaller

安裝擴充 ServiceBase 的類別來實作服務,Installs a class that extends ServiceBase to implement a service. 當安裝服務應用程式時,安裝公用程式會呼叫這個類別。This class is called by the install utility when installing a service application.

ServiceProcessDescriptionAttribute

指定屬性或事件的描述。Specifies a description for a property or event.

ServiceProcessInstaller

Installs an executable containing classes that extend ServiceBase.Installs an executable containing classes that extend ServiceBase. This class is called by installation utilities, such as InstallUtil.exe, when installing a service application.This class is called by installation utilities, such as InstallUtil.exe, when installing a service application.

TimeoutException

指定的逾時已經過期時,所擲回的例外狀況。The exception that is thrown when a specified timeout has expired.

結構

SessionChangeDescription

識別終端機服務工作階段變更的原因。Identifies the reason for a Terminal Services session change.

列舉

PowerBroadcastStatus

指示系統的電力狀態。Indicates the system's power status.

ServiceAccount

指定服務的安全性內容,該內容會定義服務的登入類型。Specifies a service's security context, which defines its logon type.

ServiceControllerPermissionAccess

定義 ServiceController 使用權限類別所使用的存取等級。Defines access levels used by ServiceController permission classes.

ServiceControllerStatus

指示服務的目前狀態。Indicates the current state of the service.

ServiceStartMode

表示服務的啟動模式。Indicates the start mode of the service.

ServiceType

表示服務的類型。Represents the type of the service.

SessionChangeReason

指定終端機服務工作階段變更通知的原因。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.