URI方案启动 [英] URI scheme launching
问题描述
我已经得到了一个任务来创建一个类似于callto的协议,即在点击链接之后,会自动启动一个已安装的应用程序。
我按照微软指南了解计划应该如何喜欢。
我的方案如下所示:
HKEY_CLASSES_ROOT
slican
URL协议=
DefaultIcon(默认)=C:\Users\Okabe\Desktop\slican\SlicanP.exe,1
shell
打开
命令(默认)=C:\Users\Okabe\Desktop\slican\SlicanP.exe%1
我以为这是全部的,并用
< a href =slican:test>测试链接< / a>
< a href =slican:0049325778421>测试电话链接< / a>
没有reac Internet Explorer问我是否要搜索一个可以打开内容的程序,Chrome反应没有任何东西,就好像我点击了javascript:void(0)。
感谢您的帮助!
当我在Windows 7上尝试时,您显示的注册对我来说完全正常。当我调用一个 slican时,我注册的SlicanP.exe的本地应用程序运行正常:
来自开始|的URL运行
菜单,并从Windows资源管理器的地址栏内。注意事项。
请注意,Internet Explorer运行在较低的完整性安全上下文中,因此可能无权运行本地程序。当我尝试点击HTML链接到 slican:
URL,或在地址中键入 slican:
URL酒吧,IE在执行本地应用程序时遇到问题(甚至在提示许可后)。我不得不以管理员身份运行IE,然后本地应用程序运行正常。
此外,您真的不应该创建一个 HKEY_CLASSES_ROOT\切片直径
键。创建一个 HKEY_CURRENT_USER\Software\Classes\slican
(仅限当前用户)或 HKEY_LOCAL_MACHINE\Software\Classes\slican
(所有用户)。有关详细信息,请参阅MSDN:
更新:因为它可以在Windows 7,Microsoft可能改变了Windows 8中URL方案的注册方式。例如,手机/商店应用程序使用URI激活:
文档说有两种方法可以注册一个自定义URI方案:
Internet Explorer使用两种机制来注册新的可插拔协议处理程序。第一种方法是注册URI方案名称及其关联的应用程序,以便使用该方案导航到URI的所有尝试启动应用程序(例如,注册应用程序来处理mailto:或news:URI)。第二种方法使用异步可插入协议API,它允许您通过将URI方案映射到类来定义新协议。
您正在做第一个尝试使用第二个。
但是,我只是注意到异步可插入协议在旧的API部分的MSDN上列出,它具有以下注释:第三方协议实现将不会在Windows Store应用程序中使用JavaScript,或Internet Explorer中的新Windows UI 加载。所以在Windows 8中可能或可能不起作用。
更新:我刚刚发现:
在Windows 8中,应用程序与其支持的文件类型之间的关系与以前的Windows版本不同。
文件类型和协议关联模型在Windows 8中已更改。应用程序不再能够以编程方式将其设置为文件类型或协议的默认处理程序。相反,现在用户总是控制文件类型或协议的默认处理程序。
您的应用程序可以使用现有的协议进行通信,如mailto或创建一个定制协议。协议激活扩展使您能够定义一个自定义协议或注册表来处理现有协议。
另请参阅: / p>
而这个:
I've been given a task to create a protocol similar to callto:, that - upon clicking on a link with it - would automatically launch an installed aplication.
I followed the microsoft guide on how a scheme should look like.
My scheme looks like this:
HKEY_CLASSES_ROOT
slican
URL Protocol = ""
DefaultIcon (Default) = "C:\Users\Okabe\Desktop\slican\SlicanP.exe,1"
shell
open
command (Default) = "C:\Users\Okabe\Desktop\slican\SlicanP.exe" "%1""
I thought that was all and tested it with
<a href="slican:test">test link</a>
<a href="slican:0049325778421">test telephone link</a>
There was no reaction whatsoever. Internet Explorer asked me if I want to search for a program that can open the content and Chrome responded with nothing, as if I clicked javascript:void(0).
How to get that worked?
Thank you for your help!
The registration you show works perfectly fine for me when I try it on Windows 7. The local app I registered in place of SlicanP.exe ran fine when I invoked a slican:
URL from the Start | Run
menu, and from within the address bar of Windows Explorer. So the registration works.
Do be aware that Internet Explorer runs in a lower integrity security context, so it may not have rights to run local programs. When I tried to click on an HTML link to a slican:
URL, or type a slican:
URL in the address bar, IE had trouble executing the local app (even after prompting for permission). I had to ran IE as an administrator, then the local app ran just fine.
Also, you really should not be creating a HKEY_CLASSES_ROOT\slican
key directly. Create a HKEY_CURRENT_USER\Software\Classes\slican
(current user only) or HKEY_LOCAL_MACHINE\Software\Classes\slican
(all users) instead. Refer to MSDN for more details:
Merged View of HKEY_CLASSES_ROOT
Update: Since it works in Windows 7, Microsoft probably changed how URL schemes are registered in Windows 8. For instance, phone/store apps use URI activation:
The documentation says there are two ways to register a custom URI scheme:
Internet Explorer uses two mechanisms for registering new pluggable protocol handlers. The first method is to register a URI scheme name and its associated application so that all attempts to navigate to a URI using that scheme launch the application (for example, registering applications to handle mailto: or news: URIs). The second method uses the Asynchronous Pluggable Protocols API, which allows you to define new protocols by mapping the URI scheme to a class.
You are doing the first. Try using the second instead.
However, I just noticed that "Asynchronous Pluggable Protocols" is listed on MSDN in the "Legacy APIs" section, and it has the following note: "Third-party protocol implementations won't load in Windows Store apps using JavaScript, or in the Internet Explorer in the new Windows UI.". So it may or may not work in Windows 8.
Update: I just found this:
Guidelines for file types and URIs
In Windows 8, the relationship between apps and the file types they support differs from previous versions of Windows.
Walkthrough: using Windows 8 Custom Protocol Activation
The file type and protocol association model has changed in Windows 8. Apps are no longer able to programmatically set themselves as the default handler for a file type or protocol. Instead, now the user always controls what the default handler is for a file type or protocol.
Your app can use existing protocols for communication, such as mailto, or create a custom protocol. The protocol activation extension enables you to define a custom protocol or register to handle an existing protocol.
Also have a look at this:
Setting mailto: protocol handler programmatically in Windows 8
And this:
这篇关于URI方案启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!