ServiceController 建構函式

定義

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

多載

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針對 參數,您可以使用 「.」 來代表本機電腦。

適用於