Difference between revisions of "Working with Windows Services in C Sharp"

From RiceFamily Wiki
Jump to: navigation, search
 
(No difference)

Latest revision as of 18:42, 12 April 2015


using System.ServiceProcess;

ServiceController sc = new ServiceController(SERVICENAME);

switch (sc.Status) {

case ServiceControllerStatus.Running:
return "Running";
case ServiceControllerStatus.Stopped:
return "Stopped";
case ServiceControllerStatus.Paused:
return "Paused";
case ServiceControllerStatus.StopPending:
return "Stopping";
case ServiceControllerStatus.StartPending:
return "Starting";
default:
return "Status Changing";

}