C# 如何获取 Adob​​e Reader 完整路径(包括可执行文件名)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10891939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:40:31  来源:igfitidea点击:

How to get Adobe Reader full path(including executable file name)?

c#adobe-reader

提问by Hyman

it's possible? I need to get the full path of Adobe Reader including the executable name. I'm looking for on windows registries, the closer that I did was found the full path without executable name. Thanks in advance.

这是可能的?我需要获取 Adob​​e Reader 的完整路径,包括可执行文件名称。我正在寻找 Windows 注册表,我越接近找到没有可执行文件名称的完整路径。提前致谢。

my code:

我的代码:

var adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe").OpenSubKey("Acrobat Reader");
var version = adobe.GetSubKeyNames().First();
var path = adobe.OpenSubKey(version).OpenSubKey("installer").GetValue("path");

Thanks in advance.

提前致谢。

采纳答案by Faraday

One of these should do it for you:

其中之一应该为你做:

    var adobe = Registry.LocalMachine
                        .OpenSubKey("Software")
                        .OpenSubKey("Microsoft")
                        .OpenSubKey("Windows")
                        .OpenSubKey("CurrentVersion")
                        .OpenSubKey("App Paths")
                        .OpenSubKey("AcroRd32.exe");

    var path = adobe.GetValue("");

    var adobeOtherWay = Registry.LocalMachine
                                .OpenSubKey("Software")
                                .OpenSubKey("Classes")
                                .OpenSubKey("acrobat")
                                .OpenSubKey("shell")
                                .OpenSubKey("open")
                                .OpenSubKey("command");

    var pathOtherWay = adobeOtherWay.GetValue("");

Pick one and run with it ;)

选择一个并运行它;)

回答by Alex

I found a problem with the "adobeOtherWay" solution. If Adobe Acrobat(not reader) is installed, then the path will point to Acrobat.exe and not the reader's exe.(I wanted to comment to above, but don't have enough reputation)

我发现“adobeOtherWay”解决方案存在问题。如果安装了 Adob​​e Acrobat(not reader),则路径将指向 Acrobat.exe 而不是 reader 的 exe。(我想对上面发表评论,但没有足够的声望)

回答by Johan

I'm using : HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe It gives me the full path and exe- name of the installed Acrobat Reader, just what you need.

我正在使用:HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe 它为我提供了已安装 Acrobat Reader 的完整路径和 exe 名称,正是您需要的。