在Windows机器上有一个以编程方式找出哪个应用程序负责在带有特定扩展名打开文件?扩展名、应用程序、有一个、方式

2023-09-03 22:05:04 作者:一轮清风月

在Windows机器上,有没有办法以编程方式找出哪个应用程序负责在带有特定扩展名打开文件?假设我想找出编程的应用程序负责打开.PDF文件。 (不关心,如果你有C#或VB.NET code)

On a Windows machine, is there a way to programmatically find out which application is responsible for opening files with a particular extension? Suppose I want to find out programmatically which application is responsible for opening .PDF files. (don't care if you have C# or VB.NET code)

推荐答案

我不会给你code,而是告诉你,这个信息被存储 - 我敢肯定,你可以计算出剩下的你自己:)

I won’t give you code but rather tell you where this information is stored – I’m sure you can figure out the rest on your own :)

所以,所有的数据都存储在注册表里面, HKEY_CLASSES_ROOT 。以的.pdf 作为一个例子,有一个关键的的.pdf 包含 AcroExch.Document ,因为它的默认值(在我的设置最少)。

So, all that data is stored inside the registry, in HKEY_CLASSES_ROOT. Taking .pdf as an example, there is a key .pdf which contains AcroExch.Document as it’s default value (on my setup at least).

再在 HKEY_CLASSES_ROOT 有一个关键 AcroExch.Document \壳\开放\命令和一个包含C:\ Program Files文件(x86)的\的Adobe \ Acrobat中8.0 \ Acrobat中\ Acrobat.exe%1作为它的值。这就是正在使用我的电脑上打开一个PDF文件。

Again in HKEY_CLASSES_ROOT there is a key AcroExch.Document\Shell\Open\Command and that one contains "C:\Program Files (x86)\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe" "%1" as its value. And that’s what is being used on my computer to open a PDF file.