Check Adobe Reader is installed (C#)?

18,695

Solution 1

using System;
using Microsoft.Win32;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe");
            if(null == adobe)
            {
                var policies = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Policies");
                if (null == policies)
                    return;
                adobe = policies.OpenSubKey("Adobe");
            }
            if (adobe != null)
            {
                RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");
                if (acroRead != null)
                {
                    string[] acroReadVersions = acroRead.GetSubKeyNames();
                    Console.WriteLine("The following version(s) of Acrobat Reader are installed: ");
                    foreach (string versionNumber in acroReadVersions)
                    {
                        Console.WriteLine(versionNumber);
                    }
                }
            }
        }
    }
}

Solution 2

The only solution which works for me is:

    var adobePath = Registry.GetValue(
@"HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe", string.Empty, string.Empty);

Then I check if adobePath != null then Adobe reader is installed.

This way I will get also the path to the acrobat reader executable.

Solution 3

Please also consider people running 64bit operating systems and potentially running either 32bit or 64bit versions of adobe reader.

The following code is a modified version of Abmv's posted solution, but this will check to see if 64bit versions of adobe reader are installed first before checking for 32bit versions.

Hope this makes sense! :-)

using System;
using Microsoft.Win32;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            RegistryKey software = Registry.LocalMachine.OpenSubKey("Software");

            if (software != null)
            {
                RegistryKey adobe;

                // Try to get 64bit versions of adobe
                if (Environment.Is64BitOperatingSystem)
                {
                    RegistryKey software64 = software.OpenSubKey("Wow6432Node");

                    if (software64 != null)
                        adobe = software64.OpenSubKey("Adobe");
                }

                // If a 64bit version is not installed, try to get a 32bit version
                if (adobe == null)
                    adobe = software.OpenSubKey("Adobe");

                // If no 64bit or 32bit version can be found, chances are adobe reader is not installed.
                if (adobe != null)
                {
                    RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");

                    if (acroRead != null)
                    {
                        string[] acroReadVersions = acroRead.GetSubKeyNames();
                        Console.WriteLine("The following version(s) of Acrobat Reader are installed: ");

                        foreach (string versionNumber in acroReadVersions)
                        {
                            Console.WriteLine(versionNumber);
                        }
                    }
                    else
                        Console.WriteLine("Adobe reader is not installed!");
                }
                else
                    Console.WriteLine("Adobe reader is not installed!");
            }
        }
    }
}
Share:
18,695

Related videos on Youtube

Sauron
Author by

Sauron

Updated on July 02, 2020

Comments

  • Sauron
    Sauron almost 4 years

    How can I check whether Adobe reader or acrobat is installed in the system? also how to get the version? ( In C# code )

    • OregonGhost
      OregonGhost almost 15 years
      If what you actually want to do is to check if a PDF viewer is installed on the system, DON'T check for Adobe Reader. I and some of my co-workers are using Foxit Reader, which is way better than Adobe Reader.
  • Chuck Savage
    Chuck Savage over 10 years
    Adobe is either putting it somewhere else or my Windows8 machine has it differently, modified the above code to try find Adobe in Software.Policies
  • Nada N. Hantouli
    Nada N. Hantouli about 9 years
    Is there a way to check in c# code if the installed adobe reader is up to date, or if there is a new update available?
  • Nada N. Hantouli
    Nada N. Hantouli about 9 years
    Is there a way to check in c# code if the installed adobe reader is up to date, or if there is a new update available?
  • Fabián Romo
    Fabián Romo over 3 years
    I uninstalled acrobat, but the registry is maintained, and the version (adobe variable) is not null and has the latest version.

Related