如何查看系统中是否安装了 Adobe reader 或 acrobat?还有如何获得版本?(在 C# 代码中)
问问题
18709 次
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 阅读器。
这样,我还将获得 acrobat reader 可执行文件的路径。
于 2013-11-27T14:59:54.210 回答
7
还请考虑运行 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!");
}
}
}
}
于 2013-04-28T21:53:48.280 回答