Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Adobe Reader is installed (C#)?

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

like image 790
Sauron Avatar asked Jun 09 '09 09:06

Sauron


2 Answers

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);
                    }
                }
            }
        }
    }
}
like image 196
abmv Avatar answered Sep 24 '22 02:09

abmv


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.

like image 20
Pinte Dani Avatar answered Sep 22 '22 02:09

Pinte Dani