Get installed applications in a system

后端 未结 14 1226
遥遥无期
遥遥无期 2020-11-22 08:28

How to get the applications installed in the system using c# code?

14条回答
  •  青春惊慌失措
    2020-11-22 09:07

    You can take a look at this article. It makes use of registry to read the list of installed applications.

    public void GetInstalledApps()
    {
        string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
        using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
        {
            foreach (string skName in rk.GetSubKeyNames())
            {
                using (RegistryKey sk = rk.OpenSubKey(skName))
                {
                    try
                    {
                        lstInstalled.Items.Add(sk.GetValue("DisplayName"));
                    }
                    catch (Exception ex)
                    { }
                }
            }
        }
    }
    

提交回复
热议问题