如何在 Windows 10 中创建可以处理 URL:callto 和 URL:tel 协议的 WPF 应用程序? [英] How do I create a WPF application that can handle the URL:callto and URL:tel protocols in Windows 10?

查看:89
本文介绍了如何在 Windows 10 中创建可以处理 URL:callto 和 URL:tel 协议的 WPF 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是创建一个 WPF 应用程序,当用户单击浏览器(Chome、IE)中的 callto: 和 tel: 链接时,打开它们的默认应用程序是我创建的 Windows 10 WPF 应用程序并处理它们.

我已尝试通过编写脚本并手动输入 Visual Studio 输出的已发布 .exe 的路径来更改注册表,但每当我单击 callto: 或 tel: 链接默认程序时,这些都不起作用打开的还是Skype等voip应用.

我已将 [HKEY_CLASSES_ROOT\tel\shell\open\command]Computer\HKEY_CLASSES_ROOT\callto\shell\open\command 更改为 "C:\App\bin\Release\app.publish\App.exe" -c "call\%1" (这是我程序的.exe)

我希望浏览器提示我打开应用程序.

解决方案

您是否阅读了 这个页面,解释了如何注册为快捷方式的消费者.

<块引用>

要注册应用程序以处理特定的 URI 方案,请将新键以及适当的子键和值添加到 HKEY_CLASSES_ROOT.根密钥必须与添加的 URI 方案相匹配.例如,要添加警报:"方案,请在 HKEY_CLASSES_ROOT 中添加警报键,如下所示:

HKEY_CLASSES_ROOT警报网址协议 = ""

<块引用>

在这个新键下,URL 协议字符串值表明这个键声明了一个自定义的可插拔协议处理程序.如果没有这个键,处理程序应用程序将不会启动.该值应为空字符串.

还应为 DefaultIcon 和 shell 添加键.DefaultIcon 键的默认字符串值必须是要用作此新 URI 方案的图标的文件名.该字符串采用路径,图标索引"的形式,最大长度为 MAX_PATH.shell 键下的第一个键的名称应该是一个动作动词,例如 open.在此键下,命令键或 DDEEXEC 键指示应如何调用处理程序.命令和 DDEEXEC 键下的值描述了如何启动处理新协议的应用程序.

最后,默认字符串值应包含新 URI 方案的显示名称.以下示例显示了如何注册应用程序(在本例中为 alert.exe)来处理警报方案.

HKEY_CLASSES_ROOT警报(默认)=URL:警报协议"网址协议 = ""默认图标(默认) = "alert.exe,1"壳打开命令(默认) = "C:\Program Files\Alert\alert.exe" "%1"

<块引用>

当用户单击包含您的自定义 URI 方案的链接时,Windows Internet Explorer 会启动为该 URI 方案注册的可插入协议处理程序.如果注册表中指定的打开命令包含 %1 参数,则 Internet Explorer 会将 URI 传递给已注册的可插入协议处理程序应用程序.

My task is to create a WPF application that when users click callto: and tel: links in the browser (Chome, IE) the default application that opens them is the Windows 10 WPF application that I have created and to handle them.

I have tried changing the registry by writing a script and by manually entering the path to my published .exe that Visual Studio has output but neither of these has worked, whenever I click a callto: or tel: link the default program that is opened is still a voip application such as Skype.

I have changed the [HKEY_CLASSES_ROOT\tel\shell\open\command] and Computer\HKEY_CLASSES_ROOT\callto\shell\open\command to "C:\App\bin\Release\app.publish\App.exe" -c "call\%1" (which is the .exe of my program)

I expect to be prompted by the browser to open the application.

解决方案

Have you read this page, which explains how to register as a consumer of shortcuts.

To register an application to handle a particular URI scheme, add a new key, along with the appropriate subkeys and values, to HKEY_CLASSES_ROOT. The root key must match the URI scheme that is being added. For instance, to add an "alert:" scheme, add an alert key to HKEY_CLASSES_ROOT, as follows:

HKEY_CLASSES_ROOT
    alert
        URL Protocol = ""

Under this new key, the URL Protocol string value indicates that this key declares a custom pluggable protocol handler. Without this key, the handler application will not launch. The value should be an empty string.

Keys should also be added for DefaultIcon and shell. The Default string value of the DefaultIcon key must be the file name to use as an icon for this new URI scheme. The string takes the form "path, iconindex" with a maximum length of MAX_PATH. The name of the first key under the shell key should be an action verb, such as open. Under this key, a command key or a DDEEXEC key indicate how the handler should be invoked. The values under the command and DDEEXEC keys describe how to launch the application handling the new protocol.

Finally, the Default string value should contain the display name of the new URI scheme. The following example shows how to register an application, alert.exe in this case, to handle the alert scheme.

HKEY_CLASSES_ROOT
 alert
    (Default) = "URL:Alert Protocol"
      URL Protocol = ""
    DefaultIcon
      (Default) = "alert.exe,1"
    shell
      open
         command
            (Default) = "C:\Program Files\Alert\alert.exe" "%1"

When a user clicks a link containing your custom URI scheme, Windows Internet Explorer launches the pluggable protocol handler registered for that URI scheme. If the specified open command specified in the registry contains a %1 parameter, Internet Explorer passes the URI to the registered pluggable protocol handler application.

这篇关于如何在 Windows 10 中创建可以处理 URL:callto 和 URL:tel 协议的 WPF 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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