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

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

问题描述

UWP 应用是否可以使用任意命令行参数启动其桌面桥(完全信任的应用程序组件)?我看到了指定参数组"的能力(请参阅 https://docs.microsoft.com/en-us/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?

推荐答案

不,这在今天是不可能的.

No this is not possible today.

完成该场景的一种快速方法是让 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() 或类似的东西).

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/

EDIT I have posted some more details and an example on my blog: https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-2/

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

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