how to pass parameters from uwp app to pure c++ console app?

  c++, console-application, parameter-passing, uwp

i have a uwp app that launches a c++ console app (not a windows runtime component or anything related to uwp). i need the uwp app to pass a file path to the c++ console app so the console app can process it. for reference, i followed these blog posts:

https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-2/

as for the parameters, i have this code in my Package.appxmanifest file

<Extensions>
            <desktop:Extension xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" Category="windows.fullTrustProcess"
                               Executable="PTSExtractionWRTPTSExtractionWRT.exe">
                <desktop:FullTrustProcess>
                    <desktop:ParameterGroup GroupId="ExistingFile" Parameters="/existingFile"/>
                </desktop:FullTrustProcess>
            </desktop:Extension>
</Extensions>

and i launch the console app like so from MainPage.xaml.cs

if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
{
    //  store command line parameters in local settings so Launcher can retrieve them 
    ApplicationData.Current.LocalSettings.Values["parameters"] = filePath;
    var appData = ApplicationData.Current.LocalSettings; 
    await Windows.ApplicationModel.FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("ExistingFile");
}

the problem is that the filePath variable i’m sending is getting stored in the C:Users087AppDataLocalPackages930191-5d12-44d5-81c3-808263a5b2f9_qe1bgctg42gkjSettingssettings.dat file with this path and i can’t find a way to access this file from the c++ console app. what’s being sent as arguments to the c++ app is "/existingFile" from the Package.appxmanifest flie. how can i retrieve the real parameter?

Source: Windows Questions C++

LEAVE A COMMENT