【发布时间】:2021-04-06 10:41:27
【问题描述】:
我有一个启动 C++ 控制台应用程序的 UWP 应用程序(不是 Windows 运行时组件或与 UWP 相关的任何内容)。我需要 UWP 应用将文件路径传递给 C++ 控制台应用,以便控制台应用可以处理它。
作为参考,我关注了这些博客文章:
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-2/
至于参数,我的Package.appxmanifest文件中有这段代码:
<Extensions>
<desktop:Extension xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
Category="windows.fullTrustProcess"
Executable="PTSExtractionWRT\PTSExtractionWRT.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="ExistingFile" Parameters="/existingFile"/>
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
然后我从 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");
}
问题是我发送的 filePath 变量正在使用此路径存储在 C:\Users\14087\AppData\Local\Packages\23930191-5d12-44d5-81c3-808263a5b2f9_qe1bgctg42gkj\Settings\settings.dat 文件中,我找不到从 C++ 控制台应用程序访问此文件的方法。
作为参数发送到 C++ 应用程序的是来自 Package.appxmanifest 文件的 "/existingFile"。
我怎样才能找回真正的参数?
【问题讨论】:
-
看看这是否会引导您找到解决方案:stackoverflow.com/a/56364195/5652483
标签: c++ uwp parameter-passing console-application