从通用 Windows 应用程序打开外部应用程序 [英] Open external application from Universal Windows app

查看:43
本文介绍了从通用 Windows 应用程序打开外部应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户在我的应用中选择视频通话"选项时,我需要打开一个外部应用(Cisco Jabber Video for Telepresence).

I need to open an external application (Cisco Jabber Video for Telepresence) when a user selects the "video call" option in my app.

我发现无法在通用应用程序中打开可执行文件的位置...

I have found that it is not possible to open the location of the executable in a Universal app...

我还发现当应用程序没有与任何 URI 方案关联时,我无法打开它...

I have also found that I cannot open an application when it is not associated with any URI schemes...

有什么办法可以做到这一点吗?

Is there any way I can do this?

推荐答案

感谢 Microsoft MVA,我们为我们提供了一些选项(您只需要解决它们):

Thanks to Microsoft MVA, some options were presented to us (you just have to fiddle them out):

解决方案 1(由 此 Microsoft MVA 教程):
如果你想启动一个特定的应用程序,你必须创建一个 URI 方案注册,只有你想要启动的特定应用程序才能处理.使用 Launcher,您可以调用一个指定的 URI,该 URI 仅由一个应用程序处理(例如 my-cool-uri-scheme://start?param1=123&param2=ABC).

Solution 1 (recommended by this Microsoft MVA tutorial):
If you want to start a specific application, you have to create a URI scheme registration, that only the specific application you want to start can handle. Using the Launcher, you can call a specified URI that will only be handled by one application (e.g. my-cool-uri-scheme://start?param1=123&param2=ABC).

注意:用户始终可以最终选择以指定 URI 启动哪个应用(这就是 Microsoft 推荐此解决方案的原因).

Note: The user will always have the final choice which app to start with a specified URI (that's why this solution is recommended by Microsoft).

以下解决方案很可能只适用于企业环境!

解决方案 2(干净 解决方法):
您必须编写一个代理 Windows 应用程序.
此代理应用程序(几乎与解决方案 1 中的一样)使用特定的文件扩展名注册自己.
然后从您的 UWP 应用中调用包含参数的虚构文件路径(例如 C:/Users/CURRENTUSER/AppData/Roaming/YOURAPP/PARAM1/PARAM2/PARAM3/open.my-cool-extension) - 或事件包含参数的文件本身(例如 XML 或 RESTful).
然后,处理应用程序将使用这些信息以给定的参数启动特定应用程序(使用 Process.Start).

Solution 2 (clean workaround):
You have to write a proxy Windows application.
This proxy application (almost as in solution #1) registers itself with a specific file extension.
From your UWP app, you then call an imaginary file path containing your parameters (e.g. C:/Users/CURRENTUSER/AppData/Roaming/YOURAPP/PARAM1/PARAM2/PARAM3/open.my-cool-extension) - or event the file itself containing the parameters (e.g. XML or RESTful).
The handling application will then use those information to start a specific application (using Process.Start) with your given parameters.

解决方案 3( 解决方法):
您必须编写一个观察 Windows 应用程序.此应用程序创建一个 FileSystemWatcher 收听特定文件夹.那么为什么这是肮脏的解决方法?因为你...

Solution 3 (dirty workaround):
You have to write an observing Windows application. This application creates a FileSystemWatcher listening to a specific folder. So why is this the dirty workaround? Because you...

  1. 必须创建一个 FileSystemWatcher 永久监视 UWP 应用的特定放置目录.
  2. 用户无法控制会发生什么(无法​​覆盖应用程序以启动)
  1. Have to create a FileSystemWatcher permanently watching a specific drop directory for you UWP app.
  2. The user has no control about what will happen (no possibility to override the application to start)

这篇关于从通用 Windows 应用程序打开外部应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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