Paulo
Paulo

Reputation: 619

Verify if Visual C++ 2008 SP1 Redistributable Package is Installed?

Is there a way to know if Visual C++ 2008 SP1 Redistributable Package is installed in the machine using C#.

Many thanks,
Paulo

Upvotes: 1

Views: 1906

Answers (1)

Claudiu Mihaila
Claudiu Mihaila

Reputation: 1332

you can actually find out if any program is installed with this function:

public bool IsProgramInstalled(string displayName)
{
      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))
                  {
                        if(sk.GetValue("DisplayName") == displayName))
                        {
                            return true;
                        }
                  }
            }
      }
      return false;
}

and you can call it like this:

bool isInstalled = IsProgramInstalled("Microsoft .NET Framework 3.5 SP1");

Please search the registry to find exactly the DisplayName of the Visual C++ 2008 SP1 Redistributable Package.

Hope this helps.

Upvotes: 1

Related Questions