C#小技巧系列之二:获取系统所有服务信息
来源:互联网 发布:淘宝中宝贝卖点怎么写 编辑:程序博客网 时间:2024/04/28 15:09
说明:本人准备写一些C#有关的小技巧系列文章,这些文章含金量并不高,代码难度不大,不过因为问的次数比较多,从而导致本人决定用自己所知的方式写这一系列文章,可以看做“趣味导学”系列吧。
这是一个获取系统所有服务的程序,为了简化程序,代码仍以控制台形式提供,大家可以另外封装自己希望的功能。
核心代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceProcess;
namespace Study
...{
public class ServiceInfo
...{
public void ShowServiceInfo()
...{
ServiceController[] services=System.ServiceProcess.ServiceController.GetServices();
System.Console.WriteLine("Service名称 Service显示名称 Service状态");
for (int i = 0; i < services.Length; i++)
...{
System.Console.WriteLine(string.Format("{0} {1} {2}", services[i].ServiceName, services[i].DisplayName, services[i].Status.ToString()));
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.ServiceProcess;
namespace Study
...{
public class ServiceInfo
...{
public void ShowServiceInfo()
...{
ServiceController[] services=System.ServiceProcess.ServiceController.GetServices();
System.Console.WriteLine("Service名称 Service显示名称 Service状态");
for (int i = 0; i < services.Length; i++)
...{
System.Console.WriteLine(string.Format("{0} {1} {2}", services[i].ServiceName, services[i].DisplayName, services[i].Status.ToString()));
}
}
}
}
启动代码:
using System;
using System.Collections.Generic;
using System.Text;
namespace Study
...{
class Program
...{
static void Main(string[] args)
...{
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.ShowServiceInfo();
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Text;
namespace Study
...{
class Program
...{
static void Main(string[] args)
...{
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.ShowServiceInfo();
Console.ReadLine();
}
}
}
- C#小技巧系列之二:获取系统所有服务信息
- C#小技巧系列之三:获取系统进程信息
- C#小技巧系列之一:获取系统有关信息
- C#小技巧系列之四:获取本地网络信息
- C#小技巧系列之四:获取本地网络信息
- 通过VBS 获取系统所有服务信息
- Android系统信息获取 之二:版本信息获取
- Android系统信息获取 之二:版本信息获取
- C#获取系统信息
- C# 获取系统信息
- C#获取系统信息
- Android开发之获取系统所有进程信息。
- AutoLayout小技巧系列(二)
- vc获取系统服务信息
- vc获取系统服务信息
- vc获取系统服务信息
- C#获取系统版本信息
- C# 获取系统硬件信息
- 全民有房住还是全民有房产?
- Piss Off
- 艾夫斯堡 vs 佐加頓斯
- 目标决定行动
- 妻子
- C#小技巧系列之二:获取系统所有服务信息
- 解决XP局域网访问故障十八招
- 炫客网 尝试Web2.0 盈利新模式
- 秋的blog在csdn正式落户
- 修改鼠标光标的形状(二)
- 使用maven构建项目java.nio.BufferOverflowException问题的解决
- SD卡+读卡器做USB启动盘
- jdk,myeclipse,eclipse,tomcat安装
- 儿子满月