如何使用 fulltrustlauncher 在 uwp 应用程序中启动 .exe 文件? [英] How to launch .exe file in uwp app using fulltrustlauncher?

查看:26
本文介绍了如何使用 fulltrustlauncher 在 uwp 应用程序中启动 .exe 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我需要在我的 uwp 应用程序中执行一个 .exe 文件.我知道一个解决方案是使用 fulltrustlauncher,但是我已经搜索了很多次这个解决方案,但是我的编程水平似乎太低了,所以我很难理解他们的解释(例如:使用 UWP 从 C# 运行 EXE).那么,您如何获得此解决方案的简单示例代码?你可以分享吗?
谢谢!

for now, i need to execute a .exe file in my uwp app. I know a solution is using fulltrustlauncher, but i have searched for many times for this solution, but my programming level seem too low, so It is very difficult for me to understand their explaination (for example: Running an EXE from C# using UWP ). So, how do you have a simple sample code for this solution? can you sharing?
Thank you!

推荐答案

最后,我可以在我的 UWP 应用程序中启动我的 .exe 文件.我将像这样一步一步地描述我的解决方法:
1. 创建可执行的 .exe 文件(例如控制台应用程序)
2.将.exe文件复制到你的UWP应用程序启动文件夹(例如:Assets文件夹)
3. 在 UWP App 解决方案资源管理器中,在参考 > 通用 Windows > 扩展"下添加对Windows Desktop Extensions For The UWP v10.0.14393.0"(或更高版本)的引用.
4. 在 UWP 应用解决方案资源管理器中,打开 Package.appxmanifest xml 文件(右键单击 Package.appxmanifest 文件 --> 查看代码).添加这些命名空间

Finally, I can launch my .exe file in my UWP Application. I will describe my workaround step by step like this:
1. Create your executable .exe file (for example console application)
2. copy .exe file to your UWP Application start up folder (for example: Assets folder)
3. In UWP App Solution Explorer, add reference to "Windows Desktop Extensions For The UWP v10.0.14393.0"(or higher) under "References > Universal Windows > Extensions".
4. In UWP App Solution Explorer, open Package.appxmanifest xml file (right click on Package.appxmanifest file --> view code). add these namespace

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"

标签.然后,添加此扩展名:

to Package tag. And then, add this extension:

<Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="AssetsYourExecutableFileName.exe" />
</Extensions>

应用程序标签下.然后,添加以下代码:

under Application tag. And then, add this code:

<rescap:Capability Name="runFullTrust" />

进入您的能力标签.这一步意味着:与编译器交谈以了解它应该信任 AssetsYourExecutableFileName.exe 位置中的 .exe 文件.
5. 在您的 UWP 应用程序中,每当您想启动 .exe 文件时,您都需要执行以下代码:

into your Capabilities tag. this step mean: talk to compiler to know that it shuld trust your .exe file in the AssetsYourExecutableFileName.exe location.
5. In your UWP Application whenever you want to launch the .exe file, you need to execute this code:

await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();

参考:很好的答案

这篇关于如何使用 fulltrustlauncher 在 uwp 应用程序中启动 .exe 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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