zoukankan      html  css  js  c++  java
  • C# 停止或开启服务

    //启动服务
      private void btnStar_Click(object sender, EventArgs e)
      {
      
    if (bolServiceInstalled == false)
      
    return;
      
    using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
      {
      
    if (control.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
      {
      MessageBox.Show(
    "服务启动......");
      control.Start();
      lblMessage.Text 
    = "服务已经启动......";
      }
      }
      }
      
    //停止服务
      private void btnStop_Click(object sender, EventArgs e)
      {
      
    if (bolServiceInstalled == false)
      
    return;
      
    using (System.ServiceProcess.ServiceController control = new ServiceController("Project Monitoring"))
      {
      
    if (control.Status == System.ServiceProcess.ServiceControllerStatus.Running)
      {
      MessageBox.Show(
    "服务停止......");
      control.Stop();
      lblMessage.Text 
    = "服务已经停止......";
      }
      }
      }
  • 相关阅读:
    LeetCode-Longest Substring Without Repeating Characters
    LeetCode-Add Two Numbers
    LeetCode-Two Sum
    品格的塑造
    闰年的来历
    float在内存中的存取方法
    矩阵顺时针旋转90度
    研究生毕业论文查重
    PAT1009
    PAT1008
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2104509.html
Copyright © 2011-2022 走看看