简体   繁体   English

如何在不使用注册表的情况下确定Acrobat Reader版本

[英]How to determine Acrobat Reader version without using Registry

I know that Acrobat reader is installed,but i wanna know that which version of acrobat installed? 我知道已安装Acrobat Reader,但我想知道安装了哪个版本的Acrobat? But without using Registry key. 但不使用注册表项。 There is any Acrobat reader function for getting it? 有Acrobat Reader功能可以获取它吗?

Thanks in advance 提前致谢

I used following Code but its throw exception at some places 我使用了以下代码,但是它在某些地方抛出异常

RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe");
        if (adobe != null)
        {
            RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader");
            if (acroRead != null)
            {
                string[] acroReadVersions = acroRead.GetSubKeyNames();

                string versionNos = "";
                string ResultAcrobat ="";
                foreach (string versionNumber in acroReadVersions)
                {
                    if (Convert.ToDecimal(versionNumber) >= 9)
                    {
                        ResultAcrobat = "OK";
                    }
                    versionNos += ",Version v" + versionNumber;
                }
                versionNos = versionNos.Remove(0, 1);
                AcrobatReader = versionNos;

                if (Convert.ToString(dr["ResultAcrobat"]) == "")
                {
                    ResultAcrobat = "Error";

                }

            }

Sure, but it is more hackish than reading the registry (which holds the actual application being opened). 可以,但是比读取注册表(该注册表包含正在打开的实际应用程序)更容易破解。

My suggestion if you can't read the registry is this: 如果您无法阅读注册表,我的建议是:

  • Find all files names AcroRd32.exe in the program files folder, in my case under C:\\Program Files (x86)\\Adobe ; 在程序文件文件夹中找到所有文件名AcroRd32.exe ,在我的情况下为C:\\Program Files (x86)\\Adobe
  • Get the file version from the executables found using this code: 从使用以下代码找到的可执行文件中获取文件版本:

     string[] files = Directory.GetFiles(@"C:\\Program Files (x86)\\Adobe", "AcroRd32.exe", SearchOption.AllDirectories); // determine which one to use string pathToAdobeExe = files.First(); string version = FileVersionInfo.GetVersionInfo(pathToAdobeExe).ProductVersion; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM