开发者

how to check the a particular application is install or not in a machine using c#

开发者 https://www.devze.com 2023-02-21 22:46 出处:网络
the requirement is \"I want to a program in c# which only check that a specified program is installed or not in a m开发者_运维百科achine\" and show a message that the program is installed or not.

the requirement is "I want to a program in c# which only check that a specified program is installed or not in a m开发者_运维百科achine" and show a message that the program is installed or not.

Actually, I have a project program in c#, I want that after loading my project first form the application first check the VSS is installed on my machine because VSS is required for my project.

My Operating System is Windows 7.

Thanks Hussain


You can check all the installed programs through registry entry in most of the cases. However, please note that it depends upon whether the installer did all the right things while installing the program or not.

Following code should work:

static void GetInstalled()
{
      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))
                  {
                        Console.WriteLine(sk.GetValue("DisplayName"));
                  }
            }
      }
}


Martinho Fernandes asked a fair question about OS.

If using Windows, most often you can get this data from Registry - applications when being installed create various registry keys. In this case a specific key or keys are either present or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消