Ejemplo n.º 1
0
        /// <summary>
        /// 获取当前系统正在运行的服务列表
        /// </summary>
        public static IEnumerable <string> GetStartedServiceNamesEnumerable()
        {
            var objects = new ManagementClass(WMIPath.Win32_Service.ToString()).GetInstances().Cast <ManagementObject>().ToArray();

            return(objects.Where(m => (bool)m.Properties["Started"].Value)
                   .Select(m => (string)m.Properties["Caption"].Value).OrderBy(m => m));
        }