zoukankan      html  css  js  c++  java
  • c# windows服务状态、启动和停止服务

    首先先引用System.ServiceProcess.dll

    然后在引用命名空间using System.ServiceProcess;

    ServiceController sc = new ServiceController("Server");建立服务对象
    //服务运行则停止服务
                 if (sc.Status.Equals(ServiceControllerStatus.Running))
                 {
                     sc.Stop();
                     sc.Refresh();
                 }
    //服务停止则启动服务
                 if ((sc.Status.Equals(ServiceControllerStatus.Stopped)) || (sc.Status.Equals(ServiceControllerStatus.StopPending)))
                 {
                     sc.Start();
                     sc.Refresh();
                 }
  • 相关阅读:
    移动端轮播插件
    一个简单的富文本编辑器
    animation css3
    渐变的写法
    js拖拽功能
    打子弹游戏 js
    css-vertical-centering
    css3的linear-gradient
    js模拟滚动条
    js日历
  • 原文地址:https://www.cnblogs.com/luluping/p/1809896.html
Copyright © 2011-2022 走看看