Services

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinot85
    New Member
    • Aug 2007
    • 53

    #1

    Services

    Hi,
    Is it possible to access the services in windows using the .net framework?
  • davef
    New Member
    • Sep 2007
    • 98

    #2
    Originally posted by vinot85
    Hi,
    Is it possible to access the services in windows using the .net framework?
    Yes. Try the following code:
    Code:
    ServiceController[] controllers = ServiceController.GetServices();
    foreach( ServiceController controller in controllers ){
    // Check the status of this service to see if 
    // it can be stopped
    bool bCanStop = controller.CanStop;
    
    // Check if the service recieves notification when 
    // system shuts down.
    bool bCanShutDown = controller.CanShutdown;
    
    // Check if the service can be paused and continued.
    bool bPauseNContinue = controller.CanPauseAndContinue;
    }
    Remember to reference System.ServiceP rocess assembly and put using statement up front.

    Comment

    Working...