Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to determine if ReportViewer is installed

Tags:

c#

What is the best way to find out if reportviewer and WindowsInstaller-KB893803-v2-x86 is installed on a PC? Is there a way to find out what public key to use to find out if a specific program is installed on a PC? (Tried this, didn't work)

Best Way To Determine If .NET 3.5 Is Installed This is how to check if .NET 3.5 is installed, but i take it you need a another public key to know if report viewer is installed, but I don't know how to get the public key.

All I can think of is to check if the installation directory exists on the computer, would that be an acceptable way to check?

like image 371
Ruan Avatar asked Dec 11 '25 14:12

Ruan


2 Answers

You could check in the Registry

    public bool IsInstalled()
    {
        RegistryKey registryBase = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, string.Empty);
        if (registryBase != null)
        {
            return registryBase.OpenSubKey("Software\\Microsoft\\ReportViewer\\v2.0.50727") != null;
        }
        return false;
    }
like image 150
sa_ddam213 Avatar answered Dec 14 '25 04:12

sa_ddam213


In my machine (Win7 & Server 2012), the registry key is different.

bool exist = false;
RegistryKey registryBase = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, string.Empty);
if (registryBase != null)
{
    exist = registryBase.OpenSubKey("Software\\Wow6432Node\\Microsoft\\.NETFramework\\v2.0.50727\\AssemblyFoldersEx\\ReportViewer v10") != null;
}
like image 38
eric xu Avatar answered Dec 14 '25 02:12

eric xu