VB代码获取文件关联 [英] VB Code to get file associations

查看:81
本文介绍了VB代码获取文件关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道用于获取与特定扩展名关联的文件名的代码吗?

即:如何获取用户用于打开pdf文件的文件名.

例如:Acrord32.exe .......但是可能是CutePdf.exe

只是一个例子........

我正在尝试研究vbshel​​l ........

在此先感谢您.

Does anyone know the code to get the filename that is associated with a particular extension

ie: How do I get the file name that the user is using to open a pdf file.

ie: Acrord32.exe.......but it could be CutePdf.exe

Just an example........

I am trying to research vbshell........

Thanks in advance.

推荐答案

我从这里以FYI的身份获得了此信息:
http://www.codeproject.com/KB/vb/VBFileAssociation.aspx [ ^ ]

因此,访问注册表并打开HKEY_CLASSES_ROOT部分.

然后,找到.pdf
的密钥
默认值列出了它的文件类型.

然后,在同一部分中打开该类型文件的密钥.

此键的子键为shell,子键为open,子键为command.

此命令列出了用于打开文件的默认程序(在我的情况下,它列出了"C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" "%1").

而且您没有指定VB的版本(VB6或.Net),而是在此处介绍了使用这两种方式访问​​注册表的文章:
I got this info from here as an FYI:
http://www.codeproject.com/KB/vb/VBFileAssociation.aspx[^]

So, access the registry and open up the HKEY_CLASSES_ROOT section.

Then, find the key for .pdf

The default value lists the type of file that it is.

Then, open up the key for that type of file in the same section.

This key will have a subkey of shell which has a subkey of open which has a subkey of command.

This command lists the default program used to open the file (in my case, it lists "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" "%1").

And you didn''t specify which version of VB (VB6 or .Net) but here''s an article that explains accessing the registry using both: Accessing the Registry with VB6 and VB.NET[^]


这篇关于VB代码获取文件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆