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

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

问题描述

现在,我需要在我的uwp应用程序中执行一个.exe文件.我知道一个解决方案正在使用fulltrustlauncher,但是我已经搜索了很多次此解决方案,但是我的编程水平似乎太低,因此我很难理解他们的解释(例如:

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>扩展"下添加对"UWP v10.0.14393.0的Windows桌面扩展"的引用. 4.在UWP App解决方案资源管理器中,打开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"

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

to Package tag. And then, add this extension:

<Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\YourExecutableFileName.exe" />
</Extensions>

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

under Application tag. And then, add this code:

<rescap:Capability Name="runFullTrust" />

插入您的功能标签.此步骤的意思是:与编译器联系,以了解它应该信任您在 Assets \ YourExecutableFileName.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 Assets\YourExecutableFileName.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天全站免登陆