2009-06-09 18 views
11

Adob​​e ReaderまたはAcrobatがシステムにインストールされているかどうかを確認するにはどうすればよいですか?また、どのようにバージョンを取得するには?Adob​​e Readerがインストールされていることを確認してください(C#)?

+5

あなたが実際にやりたいことは、PDFビューアがシステムにインストールされているかどうかを確認することです.Adobe Readerはチェックしないでください。私と私の同僚の一部はFoxit Readerを使用しています.Foxit ReaderはAdobe Readerよりも優れています。 – OregonGhost

答えて

21
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

アドビはそれをどこか別の場所に置いているか、私のWindows8マシンはそれとは違って、上記のコードを 'Software.Policies'で見つけようと変更しました。 –

+0

IE、Chrome、FFでうまく動作しました。 –

+0

インストールされているAdobe Readerが最新のものか、新しいアップデートがあるかどうかをc#コードでチェックする方法はありますか? –

6

(C#コードでは)また、人々は、64ビットのオペレーティングシステムを実行して、潜在的にアドビリーダーの32ビットまたは64ビットのいずれかのバージョンを実行することを検討してください。

次のコードは、Abmvの公開ソリューションの修正版ですが、32bitバージョンを確認する前に64bitバージョンのAdobe 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!"); 
      } 
     } 
    } 
} 
+0

は、IE、Chrome、FFで素晴らしいフォームを作ってくれました。 –

+0

インストールされているAdobe Readerが最新のものか、新しいアップデートがあるかどうかをc#コードでチェックする方法はありますか? –

6

私の作品唯一の解決策は以下のとおりです。

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

adobePath != nullはその後、アドビリーダーがインストールされている場合は、私が確認してください。

このようにして、私はAcrobat Readerの実行可能ファイルへのパスも取得します。

関連する問題