13

Adobe ReaderまたはAcrobatがシステムにインストールされているかどうかを確認するにはどうすればよいですか?また、バージョンを取得する方法は?(C#コードで)

4

3 に答える 3

22
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);
                    }
                }
            }
        }
    }
}
于 2009-06-09T09:26:58.520 に答える
8

私にとって有効な唯一の解決策は次のとおりです。

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

adobePath != null次に、Adobe Reader がインストールされているかどうかを確認します。

このようにして、acrobat リーダーの実行可能ファイルへのパスも取得します。

于 2013-11-27T14:59:54.210 に答える
7

また、64 ビット オペレーティング システムを実行していて、Adobe Reader の 32 ビット バージョンまたは 64 ビット バージョンを実行している可能性がある人も考慮してください。

次のコードは、Abmv の投稿されたソリューションの修正版ですが、これは 32 ビット バージョンを確認する前に、最初に 64 ビット バージョンの Adob​​e Reader がインストールされているかどうかを確認します。

これが理にかなっていることを願っています!:-)

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!");
            }
        }
    }
}
于 2013-04-28T21:53:48.280 に答える