检测并打开所有已安装的软件

时间:2017-02-07 13:16:07

标签: c# wpf

我试图用他们的名字打开已安装的软件

我使用下面的代码打开它们,但它没有检测到所有已安装的软件。

null

有没有办法检测并用他们的名字打开所有这些?

Process proc = new Process();
                    proc.EnableRaisingEvents = false;
                    proc.StartInfo.FileName = progName;
                    proc.Start();

是随输入而变化的字符串。

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此方法:

using Microsoft.Win32;

public List<string> GetAllInstalledPrograms()
    {
        List<string> res = new List<string>();

        string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
        using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
        {
            foreach (string subkey_name in key.GetSubKeyNames())
            {
                using (RegistryKey subkey = key.OpenSubKey(subkey_name))
                {
                    res.Add(subkey.GetValue("DisplayName").ToString());
                }
            }
        }

        return res;
    }