1. 程式人生 > >C#讀取登錄檔獲得安裝的軟體

C#讀取登錄檔獲得安裝的軟體



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();

                                 if(softwareName == "softName")

                                 {

                                     messageBox.show("OK");

                                 }

                            }

                        }

                    }

                }

           }