Using c++ .exe in c# UWP

John Thomas 1 Reputation point
2020-02-05T01:32:52.267+00:00

Hi All,
I have a c# UWP and want to use c++ .exe with it. I have the source for the c++ .exe and have added this project to the c# sharp project. Do I need to WAP the c++ project and reference it, or can I launch a process from the c# UWP? The c++ .exe takes a command line argument after typing in the executable filename. I just want to click a button on the c#UWP and have it perform all the c++ .exe stuff. I don't want to install the c++.exe on the hard drive, since I have the source code and project in the solution, and I don't want to go to command prompt and type stuff in. How can I get the c# UWP to execute that project included in the solution. Again, it has one command line argument to go with the .exe name. I am not well versed in c++ and do not know how to change the console executable filecode. I only have the source code for the c++ to create an executable, and I know that works.

Thank you so much for your help, I really appreciate it.
JT

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Fay Wang - MSFT 5,191 Reputation points
    2020-02-05T06:00:19.78+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    After you add the .exe in the UWP project, you need to declare it in the manifest and also add the 'runFullTrust' capability in it. You can follow the steps below. About more details, you can refer to this similar thread.

    1.Add "Windows Desktop Extensions" reference in the project. Right click the References-> Add Reference->Universal Windows->Extensions-> add Windows Desktop Extensions".

    2.Open manifest, add Extensions tag and runFullTrust capability. Suppose you put the .exe in the assets directory. About the full content of manifest, you can view it from here.

    3.When you click the button, use the following code to start your .exe.

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
    }
    
    0 comments No comments