获取系统安装的软件名字 组件

//此代码应用于,检测系统是否安装需要的组件//如果系统没有安装需要的组件,则执行此段代码//此段代码是应用于某个项目中的,所以只供参考//需要引用的命名空间using System.Windows; public void AccessInstat() { string tempType = null; object releaseType = null,uninstallString = null,displayName = null; RegistryKey currentKey = null; string[] temp = new string[] { "Microsoft System CLR Types for SQL Server 2012", "Microsoft .NET Framework 4.5 SDK" }; // int softNum = 0; RegistryKey pregkey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");//获取指定路径下的键 try { foreach (string item in pregkey.GetSubKeyNames()) //循环所有子键 { currentKey = pregkey.OpenSubKey(item); displayName = currentKey.GetValue("DisplayName"); //获取显示名称 uninstallString = currentKey.GetValue("UninstallString"); //获取卸载字符串路径 releaseType = currentKey.GetValue("ReleaseType"); //发行类型,值是Security Update为安全更新,Update为更新 bool isSecurityUpdate = false; if (releaseType != null) { tempType = releaseType.ToString(); if (tempType == "Security Update" || tempType == "Update") isSecurityUpdate = true; } if (!isSecurityUpdate && displayName != null && uninstallString != null) { switch (displayName.ToString()) { case "Microsoft System CLR Types for SQL Server 2012": temp[0] = null; break; case "Microsoft .NET Framework 4.5 SDK": temp[1] = null; break; } } } //未安装组件弹窗显示 if (temp[0] != null || temp[1] != null) { MessageBoxCus.ShowDialogs(temp, MessageBoxImage.Warning); } } catch (Exception E) { MessageBox.Show(E.Message.ToString()); } pregkey.Close(); } }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值