在 Windows 8 中注册协议处理程序 [英] Registering a protocol handler in Windows 8

查看:41
本文介绍了在 Windows 8 中注册协议处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试注册将处理链接打开的应用程序,例如 http://stackoverflow.com.我需要为 Windows 8 明确执行此操作,我在早期版本的 Windows 中使用它.根据 MSDN,这在 Win8 中发生了变化.

I'm trying to register my application that will handle opening of links, e,g, http://stackoverflow.com. I need to do this explicitly for Windows 8, I have itworking in earlier versions of Windows. According to MSDN this has changed in Win8.

我已经浏览了 MSDN 上的默认程序页面 (msdn.microsoft.com/en-us/library/cc144154.aspx).它提供了关于处理文件类型的很好的演练,但对协议的详细信息非常了解.将应用程序注册到 URL 协议介绍了设置新协议所涉及的步骤,但没有介绍如何将新处理程序正确添加到现有协议中.

I've been through the Default Programs page on MSDN (msdn.microsoft.com/en-us/library/cc144154.aspx) page on MSDN. It provides a great walkthrough on handling file types but is light on details for protocols. Registering an Application to a URL Protocol only goes over the steps involved in setting up a new protocol, but not how to correctly add a new handler to an existing protocol.

我还尝试了其他 SO 帖子中概述的注册表设置.

I've also tried the registry settings outlined in other SO posts.

还有一点,该应用程序不是 Metro/Windows Store 应用程序,因此在清单中添加条目对我不起作用.

One more thing, the application is not a Metro/Windows Store App, so adding an entry in the manifest won't work for me.

推荐答案

您在使用默认程序网页时走在正确的轨道上 - 事实上,这是我对这篇文章的参考.

You were on the right track with the Default Programs web page - in fact, it's my reference for this post.

以下是他们的例子:

首先,您需要 HKLM\SOFTWARE\Classes 中的 ProgID 来指示如何处理给它的任何输入(您的输入可能已经存在):

First, you need a ProgID in HKLM\SOFTWARE\Classes that dictates how to handle any input given to it (yours may already exist):

HKLM\SOFTWARE\Classes
     MyApp.ProtocolHandler //this is the ProgID, subkeys are its properties
        (Default) = My Protocol //name of any type passed to this
        DefaultIcon
           (Default) = %ProgramFiles%\MyApp\MyApp.exe, 0 //for example
        shell
           open
              command
                 (Default) = %ProgramFiles%\MyApp\MyApp.exe %1 //for example

然后用 Capabilities 键中的 DefaultProgram 信息填充注册表:

Then fill the registry with DefaultProgram info inside a Capabilities key:

HKLM\SOFTWARE\MyApp
    Capabilities
       ApplicationDescription
           URLAssociations
              myprotocol = MyApp.ProtocolHandler //Associated with your ProgID

最后,使用 DefaultPrograms 注册您的应用程序的功能:

Finally, register your application's capabilities with DefaultPrograms:

HKLM\SOFTWARE
      RegisteredApplications
         MyApplication = HKLM\SOFTWARE\MyApp\Capabilities

现在所有myprotocol:"链接都应该触发 %ProgramFiles%\MyApp\MyApp.exe %1.

Now all "myprotocol:" links should trigger %ProgramFiles%\MyApp\MyApp.exe %1.

这篇关于在 Windows 8 中注册协议处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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