如何使用任意参数从UWP启动完全信任(桌面桥)应用程序 [英] How to launch a full-trust (desktop bridge) app from UWP with arbitrary parameters

查看:90
本文介绍了如何使用任意参数从UWP启动完全信任(桌面桥)应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UWP应用程序是否可以使用任意命令行参数启动其Desktop Bridge(完全信任应用程序组件)?我看到了可以指定参数组的功能(请参阅 https: //docs.microsoft.com/zh-cn/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher ),但看起来它仅支持使用预定义的 ParameterGroup 。我需要使用程序确定的(在启动时)任意命令行参数来启动UWP。

Is it possible for a UWP app to launch its Desktop Bridge (full-trust application component) with arbitrary command-line arguments? I see the ability to specify "argument groups" (see https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher), but it looks like that only supports using a predefined ParameterGroup. I need to launch a UWP with programmatically-determined (at launch time) arbitrary command-line arguments. Is this possible, and if so, how?

推荐答案

今天不行。

完成该方案的一种快速方法是让UWP将命令字符串写入本地应用程序数据/设置,这在两个进程之间共享。因此,完全信任过程可以从那里启动命令字符串,然后从那里开始。

One quick way to accomplish the scenario is to have the UWP write the command string to the local app data/settings, which is shared between the two processes. So the full-trust process can then pick up the command string after its been launched from there.

更复杂的解决方案是在两个进程之间建立应用程序服务连接,然后通过该连接传递命令字符串。如果您需要在两个流程之间保持来回通信,这将很有帮助。

A more complex solution is to establish an app service connection between the two processes, and pass the command string via that connection. This will be helpful if you need to keep communicating back and forth between the two processes.

如果由于某种原因您无法更改现有的完全信任流程代码,您可以在程序包中添加一个额外的EXE,该EXE可以从应用程序数据中读取命令字符串,然后使用这些参数(使用Process.Start()或同等功能)启动实际的完全信任EXE。

If for some reason you can't change your existing full-trust process code, you could add an extra EXE to your package that just reads the command string from the app data and then launches your actual full-trust EXE with those parameters (using Process.Start() or something equivalent).

编辑
我在博客上发布了更多详细信息和示例:
> https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part- 2 /

这篇关于如何使用任意参数从UWP启动完全信任(桌面桥)应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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