ServiceController 建構函式

定義

初始化 ServiceController 類別的新執行個體。

多載

名稱 Description
ServiceController()

初始化一個與特定服務無關聯的類別新實例 ServiceController

ServiceController(String)

初始化一個與本地電腦上現有服務相關的類別新實例 ServiceController

ServiceController(String, String)

初始化與指定電腦上現有服務相關的類別新實例 ServiceController

ServiceController()

來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs

初始化一個與特定服務無關聯的類別新實例 ServiceController

public:
 ServiceController();
public ServiceController();
Public Sub New ()

適用於

ServiceController(String)

來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs

初始化一個與本地電腦上現有服務相關的類別新實例 ServiceController

public:
 ServiceController(System::String ^ name);
public ServiceController(string name);
new System.ServiceProcess.ServiceController : string -> System.ServiceProcess.ServiceController
Public Sub New (name As String)

參數

name
String

這個名稱用來識別系統中的服務。 這也可以作為該服務的顯示名稱。

例外狀況

name 無效。

範例

以下範例示範如何 ServiceController.ServiceController(String) 使用建構子建立 ServiceController 一個用來控制範例服務的物件。 此範例是本類別中提供 ServiceController 更大範例的一部分。

// Display properties for the Simple Service sample
// from the ServiceBase example.
ServiceController sc = new ServiceController("Simple Service");
Console.WriteLine("Status = " + sc.Status);
Console.WriteLine("Can Pause and Continue = " + sc.CanPauseAndContinue);
Console.WriteLine("Can ShutDown = " + sc.CanShutdown);
Console.WriteLine("Can Stop = " + sc.CanStop);
' Display properties for the Simple Service sample 
' from the ServiceBase example
Dim sc As New ServiceController("Simple Service")
Console.WriteLine("Status = " + sc.Status.ToString())
Console.WriteLine("Can Pause and Continue = " + _
    sc.CanPauseAndContinue.ToString())
Console.WriteLine("Can ShutDown = " + sc.CanShutdown.ToString())
Console.WriteLine("Can Stop = " + sc.CanStop.ToString())

適用於

ServiceController(String, String)

來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs
來源:
ServiceController.cs

初始化與指定電腦上現有服務相關的類別新實例 ServiceController

public:
 ServiceController(System::String ^ name, System::String ^ machineName);
public ServiceController(string name, string machineName);
new System.ServiceProcess.ServiceController : string * string -> System.ServiceProcess.ServiceController
Public Sub New (name As String, machineName As String)

參數

name
String

這個名稱用來識別系統中的服務。 這也可以作為該服務的顯示名稱。

machineName
String

服務所在的電腦。

例外狀況

name 無效。

-或-

machineName 無效。

備註

參數 machineName 方面,您可以使用「.」來表示本地電腦。

適用於