检测本机是否安装iis,netFramework,ASPNET

  //判断是否已经安装iis
        public static bool ExistSqlServerService(string tem)
        {
            bool ExistFlag = false;
            ServiceController[] service = ServiceController.GetServices();
            for (int i = 0; i < service.Length; i++)
            {
                if (service[i].ServiceName.ToString() == tem)
                {
                    ExistFlag = true;
                }
            }
            return ExistFlag;
        }
  }
        //判断是否安装netFramework
        private static bool GetDotNetVersions()
        {
            bool result = false;
            DirectoryInfo[] directories = new DirectoryInfo(
                Environment.SystemDirectory + @"..Microsoft.NETFramework").GetDirectories("v?.?.*");
            //string list = "";
            foreach (DirectoryInfo info2 in directories)
            {
                //list +=info2.Name.Substring(0,4)+",";
                if (info2.Name.Substring(0, 4) == "v3.5")
                {
                    result = true;
                }

            }
            return result;
        }
 //检测是否安装ASPnet,通过注册表
            string value = Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components", "ASPNET", null).ToString();
         if (value != null )
            {
                label12.Text += ",ASPNET已安装";
            }
原文地址:https://www.cnblogs.com/provedl/p/14468328.html