现在的位置: 首页 > 综合 > 正文

用c#获得电脑上安装的软件

2013年08月10日 ⁄ 综合 ⁄ 共 1130字 ⁄ 字号 评论关闭

string app ="";

                   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 (softwareName != "")

                                       {

                                           app  =
app  + "
软件名:" + softwareName +"\r\n";

                                       }

                                   }

                               }

                           }

                       }

                   }

通过注册表,获得所有的软件集合.用这个也可以判断, 某个软件是否安装在你的电脑上.

抱歉!评论已关闭.