Подтвердить что ты не робот

Проверьте, установлен ли Adobe Reader (С#)?

Как проверить, установлен ли в системе Adobe Reader или акробат? также как получить версию? (В коде С#)

4b9b3361

Ответ 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);
                    }
                }
            }
        }
    }
}

Ответ 2

Также рассмотрите пользователей, работающих с 64-битными операционными системами и потенциально работающих либо с 32-битными, либо с 64-битными версиями Adobe Reader.

Следующий код представляет собой модифицированную версию решения Abmv, но это проверит, чтобы установить, были ли установлены 64-битные версии Adobe Reader, прежде чем проверять 32-разрядные версии.

Надеюсь, это имеет смысл!: -)

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!");
            }
        }
    }
}

Ответ 3

Единственное решение, которое работает для меня, это:

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

Затем я проверяю, установлен ли adobePath != null, программа Adobe Reader.

Таким образом, я получу также путь к исполняемому файлу для чтения акробатов.