ServiceBase.CanHandlePowerEvent 屬性

定義

取得或設定值,指出服務是否可以處理電腦電源狀態變更時發生的告知。Gets or sets a value indicating whether the service can handle notifications of computer power status changes.

public:
 property bool CanHandlePowerEvent { bool get(); void set(bool value); };
public bool CanHandlePowerEvent { get; set; }
member this.CanHandlePowerEvent : bool with get, set
Public Property CanHandlePowerEvent As Boolean

屬性值

如果服務處理 PowerBroadcastStatus 類別中所指示的電腦電源狀態變更,則為 true,否則為 falsetrue if the service handles the computer power status changes indicated in the PowerBroadcastStatus class, otherwise, false.

例外狀況

這個屬性在服務啟動之後被修改。This property is modified after the service was started.

備註

當電腦電源狀態變更時,服務控制管理員(SCM)會使用的值來CanHandlePowerEvent驗證服務是否接受電源事件命令。When the computer power status changes, the Service Control Manager (SCM) verifies whether the service accepts power event commands using the value of CanHandlePowerEvent.

如果CanHandlePowerEvent OnPowerEventtrue,則會將命令傳遞至服務,並在已定義的情況下呼叫方法。If CanHandlePowerEvent is true, the command is passed to the service and the OnPowerEvent method is called if defined. 如果OnPowerEvent未在衍生類別中執行,SCM 會透過空的ServiceBase.OnPowerEvent基類方法處理電源事件。If OnPowerEvent is not implemented in the derived class, the SCM handles the power event through the empty base class ServiceBase.OnPowerEvent method.

適用於

另請參閱