首页新闻找找看学习计划

C# 怎么获取服务的描述 和服务的可执行文件的路径啊

0
[已解决问题] 解决于 2014-09-26 09:14
 
 
 
            ServiceController[] servers = ServiceController.GetServices();
            DataTable table = new DataTable();
            table.Columns.Add("DisplayName", typeof(string));
            table.Columns.Add("Description", typeof(string));
            table.Columns.Add("Status", typeof(string));
            table.Columns.Add("StartType", typeof(string));
            table.Columns.Add("LoginAs", typeof(string));
            table.Columns.Add("CanPauseAndContinue", typeof(bool));
            table.Columns.Add("CanShutdown", typeof(bool));
            table.Columns.Add("CanStop", typeof(bool));
            foreach (ServiceController item in servers)
            {
                string DisplayName = item.DisplayName;
                string ServiceName = item.ServiceName;
                string Description = "";描述
                ServiceControllerStatus Status = item.Status;
                string StartType = "";
                string LoginAs = "";
                bool CanPauseAndContinue = item.CanPauseAndContinue;
                bool CanShutdown=  item.CanShutdown;
                bool CanStop = item.CanStop;
                string path = "";//可执行文件的路径
                
                table.Rows.Add(new object[] { DisplayName, Description, Status.ToString() == "Running" ? "已启动" : "", StartType, LoginAs, CanPauseAndContinue, CanShutdown, CanStop });
            }
 
.F.的主页 .F. | 初学一级 | 园豆:5
提问于:2014-09-19 16:03
< >
分享
最佳答案
0

好吧   其实 可以查询注册表来操作,单单是服务类 是没找到解决的办法...

.F. | 初学一级 |园豆:5 | 2014-09-26 09:13
其他回答(1)
0

博主现在解决了吗 同求

_daring | 园豆:24 (初学一级) | 2016-08-10 16:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册