2009-12-22 4 views

Répondre

3
// ADD "using System.ServiceProcess;" after you add the 
// Reference to the System.ServiceProcess in the solution Explorer 
using System.ServiceProcess; 

ServiceController myService = new ServiceController();  
myService.ServiceName = "ImapiService"; 

string svcStatus = myService.Status.ToString(); 

if (svcStatus == "Running") 
{ 
    myService.Stop(); 
} 
else if(svcStatus == "Stopped") 
{ 
    myService.Start(); 
} 
else 
{ 
    myService.Stop(); 
} 
1

Que voulez-vous dire par "run"? Si vous voulez contrôler (démarrer, arrêter et manipuler) les services installés sur votre machine locale (ou distante), ServiceController est la solution.

Questions connexes