3

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?

Community
  • 1
  • 1
Ruan
  • 3,969
  • 10
  • 60
  • 87
  • Is this the built in reporting stuff? If so why do you need to know if its installed? You can distribute its dll's side by side with your app. Some of the req dll's are in the GAC but you can get them out easily enough. – cjb110 Jan 23 '13 at 08:20
  • Yes it is, but i wanted to keep the application from installing itself on the computer, because im using this to install another application. thus at the end ill have 2 apps on the computer, one of them not doing anything (only used at the install of the application) – Ruan Jan 23 '13 at 13:05
  • As I said they work with SxS, Side by Side deployment, so you could just have them all in the folder alongside your app...no installation as such. – cjb110 Jan 24 '13 at 08:21
  • Oh,, Okay, i never knew that. I'll Look into that, thank you! – Ruan Jan 24 '13 at 09:02

4 Answers4

3

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;
    }
sa_ddam213
  • 42,848
  • 7
  • 101
  • 110
2

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;
}
eric xu
  • 523
  • 5
  • 13
1

You could also query the GAC for the assemblies, as shown in this SO question.

Community
  • 1
  • 1
cjb110
  • 1,310
  • 14
  • 30
0

I did a Regshot diff on a MS Report Viewer version 10 install to find the key because neither of the others posted here were working.

Here is the actual diff results on a fresh windows server VM.

Anyways, the key I found for this version was:

SOFTWARE\Wow6432Node\Microsoft\ReportViewer\v10.0

The code I used:

public bool IsInstalledReportViewer()
{
    try
    {
        RegistryKey registryBase = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, string.Empty);
        if (registryBase != null)
        {
            // check the two possible reportviewer v10 registry keys
            return registryBase.OpenSubKey(@"Software\Microsoft\ReportViewer\v2.0.50727") != null
                || registryBase.OpenSubKey(@"Software\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\ReportViewer v10") != null
                || registryBase.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\ReportViewer\v10.0") != null;
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
        // put proper exception handling here
    }

    return false;
}
Brad C
  • 2,868
  • 22
  • 33