[英]How to determine Acrobat Reader version without using Registry
我知道已安裝Acrobat Reader,但我想知道安裝了哪個版本的Acrobat? 但不使用注冊表項。 有Acrobat Reader功能可以獲取它嗎?
提前致謝
我使用了以下代碼,但是它在某些地方拋出異常
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";
}
}
可以,但是比讀取注冊表(該注冊表包含正在打開的實際應用程序)更容易破解。
如果您無法閱讀注冊表,我的建議是:
AcroRd32.exe
,在我的情況下為C:\\Program Files (x86)\\Adobe
; 從使用以下代碼找到的可執行文件中獲取文件版本:
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.