WindowsForms获取服务名称

2021-06-11 21:05

阅读:697

标签:txt   添加   name   close   ice   build   services   nbsp   new   

  StringBuilder sb = new StringBuilder();
            ServiceController[] services = ServiceController.GetServices(); //需要添加引用程序程序集Serviceprocess

            foreach (ServiceController sController in services)
            {
                //sb.AppendFormat("{0} :{1}",sController.ServiceName,sController.Status);
                sb.AppendFormat("{0}", sController.ServiceName);
                sb.Append("\r\n");
            }
            var result = sb.ToString();
            System.IO.File.WriteAllText(@"back1.txt", result, Encoding.UTF8);
            MessageBox.Show("完成!");
            this.Close();

 

WindowsForms获取服务名称

标签:txt   添加   name   close   ice   build   services   nbsp   new   

原文地址:https://www.cnblogs.com/enych/p/10543813.html


评论


亲,登录后才可以留言!