Csharp/C Sharp by API/System.ServiceProcess/ServiceController
Версия от 15:31, 26 мая 2010; (обсуждение)
Содержание
new ServiceController
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
ServiceController scAlerter = new ServiceController("Alerter");
Console.WriteLine(scAlerter.DisplayName);
Console.WriteLine(scAlerter.CanStop);
scAlerter.Stop();
Console.WriteLine("Service stopped");
scAlerter.Start();
Console.WriteLine("Service started");
}
}
ServiceController.CanStop
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
ServiceController scAlerter = new ServiceController("Alerter");
Console.WriteLine(scAlerter.DisplayName);
Console.WriteLine(scAlerter.CanStop);
scAlerter.Stop();
Console.WriteLine("Service stopped");
scAlerter.Start();
Console.WriteLine("Service started");
}
}
ServiceController.DisplayName
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
ServiceController scAlerter = new ServiceController("Alerter");
Console.WriteLine(scAlerter.DisplayName);
Console.WriteLine(scAlerter.CanStop);
scAlerter.Stop();
Console.WriteLine("Service stopped");
scAlerter.Start();
Console.WriteLine("Service started");
}
}
ServiceController.Stop()
using System;
using System.ServiceProcess;
class MainClass
{
public static void Main()
{
ServiceController scAlerter = new ServiceController("Alerter");
Console.WriteLine(scAlerter.DisplayName);
Console.WriteLine(scAlerter.CanStop);
scAlerter.Stop();
Console.WriteLine("Service stopped");
scAlerter.Start();
Console.WriteLine("Service started");
}
}