ServiceControllerStatus 열거형

정의

서비스의 현재 상태를 나타냅니다.

public enum class ServiceControllerStatus
public enum ServiceControllerStatus
type ServiceControllerStatus = 
Public Enum ServiceControllerStatus
상속
ServiceControllerStatus

필드

ContinuePending 5

서비스 계속 명령이 보류 중입니다. 이 상태는 0x00000005로 정의된 Win32 SERVICE_CONTINUE_PENDING 상수에 해당합니다.

Paused 7

서비스가 일시 중지되었습니다. 이 상태는 0x00000007로 정의된 Win32 SERVICE_PAUSED 상수에 해당합니다.

PausePending 6

서비스 일시 중지 명령이 보류 중입니다. 이 상태는 0x00000006으로 정의된 Win32 SERVICE_PAUSE_PENDING 상수에 해당합니다.

Running 4

서비스가 실행되고 있습니다. 이 상태는 0x00000004로 정의된 Win32 SERVICE_RUNNING 상수에 해당합니다.

StartPending 2

서비스가 시작되었습니다. 이 상태는 0x00000002로 정의된 Win32 SERVICE_START_PENDING 상수에 해당합니다.

Stopped 1

서비스가 실행되고 있지 않습니다. 이 상태는 0x00000001로 정의된 Win32 SERVICE_STOPPED 상수에 해당합니다.

StopPending 3

서비스가 중지되었습니다. 이 상태는 0x00000003으로 정의된 Win32 SERVICE_STOP_PENDING 상수에 해당합니다.

예제

다음 예제에서는 클래스를 ServiceController 사용하여 TelNet 서비스의 현재 상태를 확인합니다. 서비스가 중지되면 서비스를 시작하는 예제입니다. 서비스가 실행 중인 경우 이 예제는 서비스를 중지합니다.

// Toggle the Telnet service - 
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController^ sc = gcnew ServiceController(  "Telnet" );
if ( sc )
{
   Console::WriteLine(  "The Telnet service status is currently set to {0}", sc->Status );
   if ( (sc->Status == (ServiceControllerStatus::Stopped) ) || (sc->Status == (ServiceControllerStatus::StopPending) ) )
   {
      // Start the service if the current status is stopped.
      Console::WriteLine(  "Starting the Telnet service..." );
      sc->Start();
   }
   else
   {
      // Stop the service if its status is not set to "Stopped".
      Console::WriteLine(  "Stopping the Telnet service..." );
      sc->Stop();
   }

   // Refresh and display the current service status.
   sc->Refresh();
   Console::WriteLine(  "The Telnet service status is now set to {0}.", sc->Status );

// Toggle the Telnet service -
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController sc = new ServiceController("Telnet");
Console.WriteLine("The Telnet service status is currently set to {0}",
                  sc.Status.ToString());

if  ((sc.Status.Equals(ServiceControllerStatus.Stopped)) ||
     (sc.Status.Equals(ServiceControllerStatus.StopPending)))
{
   // Start the service if the current status is stopped.

   Console.WriteLine("Starting the Telnet service...");
   sc.Start();
}
else
{
   // Stop the service if its status is not set to "Stopped".

   Console.WriteLine("Stopping the Telnet service...");
   sc.Stop();
}

// Refresh and display the current service status.
sc.Refresh();
Console.WriteLine("The Telnet service status is now set to {0}.",
                   sc.Status.ToString());

' Toggle the Telnet service - 
' If it is started (running, paused, etc), stop the service.
' If it is stopped, start the service.
Dim sc As New ServiceController("Telnet")
Console.WriteLine("The Telnet service status is currently set to {0}", sc.Status)

If sc.Status.Equals(ServiceControllerStatus.Stopped) Or sc.Status.Equals(ServiceControllerStatus.StopPending) Then
   ' Start the service if the current status is stopped.
   Console.WriteLine("Starting the Telnet service...")
   sc.Start()
Else
   ' Stop the service if its status is not set to "Stopped".
   Console.WriteLine("Stopping the Telnet service...")
   sc.Stop()
End If

' Refresh and display the current service status.
sc.Refresh()
Console.WriteLine("The Telnet service status is now set to {0}.", sc.Status)

설명

ServiceControllerStatus 이 열거형은 클래스 인스턴스 ServiceController 에서 기존 서비스가 실행 중인지, 중지되었는지, 일시 중지되었는지 또는 시작, 중지, 일시 중지 또는 계속 명령이 보류 중인지 여부를 나타내는 데 사용됩니다.

적용 대상

추가 정보