C#读取注册表,获取本机安装的软件清单
应一个网友的需求,写了下面的,获取本机安装的软件的清单,希望对有需要的人,有帮助吧
using Microsoft.Win32;
using (RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false)) { if (key != null) { foreach (string keyName in key.GetSubKeyNames()) { using (RegistryKey key2 = key.OpenSubKey(keyName, false)) { if (key2 != null) { string softwareName = key2.GetValue("DisplayName", "").ToString(); string installLocation = key2.GetValue("InstallLocation", "").ToString(); if (!string.IsNullOrEmpty(installLocation)) { this.textBox1.AppendText(string.Format("软件名:{0} -- 安装路径:{1}\r\n", softwareName, installLocation)); } } } } } }
将取得的结果,放入 textBox1 中显示,每行一个。
作者: 三角猫
http://www.zu14.cn/
转载请保留此信息