我找到了从此处获取已安装程序列表的解决方案。 Get installed applications in a system
但未获取所有已安装的程序,缺少列表中的某些程序。如何在不跳过的情况下获取所有程序列表
这是我的代码。
try
{
object line;
string softwareinstallpath = string.Empty;
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (var baseKey =RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
{
using (var key = baseKey.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
{
using (var subKey = key.OpenSubKey(subkey_name))
{
line = subKey.GetValue("DisplayName");
if (line != null)
{
listBox1.Items.Add(line);
if (line != null && (line.ToString().ToUpper().Contains("SKYPE")))
{
MessageBox.Show("SKYPE");
}
if (line != null && (line.ToString().ToUpper().Contains("QBFC")))
{
softwareinstallpath = subKey.GetValue("InstallLocation").ToString();
listBox1.Items.Add(subKey.GetValue("InstallLocation"));
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
}