Windows注册表-注册应用程序以打开文件类型 [英] Windows registry - register an application to open a file type

查看:159
本文介绍了Windows注册表-注册应用程序以打开文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为具有自定义URI方案和自己的文件类型的应用程序安装程序.用launcher.bat执行的应用程序,在注册表中,我已经设置了launcher.bat来执行此操作. 它应该正常工作,除非我要注册应用程序,并使用它的名称而不是launcher.bat在浏览器和浏览器中显示为正在打开的应用程序.

I'm making an installer for an application which has a custom URI scheme and its own file type to open with it. The application executed with a launcher.bat, In the registry I've set the launcher.bat to do so. It works as it should be, unless I want to register the application wit its name to be shown as opening application both in exporer and browsers instead of launcher.bat.

以下是安装程序脚本应用的注册表文件(它是动态生成的,因此也不必介意应用程序路径):

The registry file that applied by the installer script is the following (it is gets generated dynamically, so don't mind the application path as well):

Windows Registry Editor Version 5.00

; ---- Add myext extension
[-HKEY_CLASSES_ROOT\.myext]

[HKEY_CLASSES_ROOT\.myext]
"content-type"="application/myext+xml"
@="myapp"


; ---- Add myapp for protocol
[-HKEY_CLASSES_ROOT\myapp]

[HKEY_CLASSES_ROOT\myapp]
@="URL:<Application Protocol>"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
@="MyApplication.exe,1"

[HKEY_CLASSES_ROOT\myapp\shell]
@="open"

[HKEY_CLASSES_ROOT\myapp\shell\open]
@="Open with My Application"

[HKEY_CLASSES_ROOT\myapp\open\command]
@="\"C:\\Program Files (x86)\\My Application\\launcher.bat\" \"%1\""

我还应该添加到注册表中什么呢?

What else should I add to the registry to do so?

推荐答案

经过几天的挖掘,我找到了解决方法:

After a few days of digging, I have found the solution:

上面的注册表将扩展名分配给启动器(或任何可执行文件)以用来打开启动器,但OS仅将可执行文件的名称显示为关联程序-很好,因为未注册.这可能会显示在文件的属性窗口中,与之相关的是,在exprorer中,当您右键单击该文件并选择打开方式"时,甚至在注册了URI方案的浏览器中,也是如此.

The registry above assigns extension to the launcher (or any executable) to open it with, but the OS only shows the executable name as the associated program - which is fine, because It wasn't registred. This could be shown on the properties window of the file which are associated to, in exprorer, when you right click on the file and choose open with, and even in browesers when a URI scheme is registed.

为此,还必须在注册表中注册该应用程序.在浏览了互联网之后,终于在 MSDN 这样做的额外注册表更改.

To do so, the application has to be registred as well in the registry. After digging the internet, finally found on MSDN the extra registry changes that does so.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\MyApplicationLauncher.bat]
FriendlyAppName = "My Application"
DefaultIcon = "<MyApplicationPath>\MyApplication.exe,1"

请注意,使用launcher.batstart.bat之类的应用程序名称可能会导致冲突;为了证明其唯一性,我必须在安装程序包中对其进行重命名以进行标识.

Note that using application names like launcher.bat or start.bat might cause conflicts; to prove its uniqueness, I had to rename it in the installer package to identify it.

这篇关于Windows注册表-注册应用程序以打开文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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