我需要从另一个获取此类参数的应用程序启动一个带有布尔参数的应用程序。两者都是Windows中安装的应用程序。该参数的目的是在启动的应用程序中启用/禁用控件。
我找到了一种使用参数启动应用程序的方法(如"?MyParameter=true"
之类的参数)。我在应用A中使用Windows.System.Launcher.LaunchUriAsync(myUriWithParameters);
,它会成功触发,但不知道如何从新应用中获取该参数。这可能吗?我怎么能这样做?
提前致谢。
答案 0 :(得分:1)
OnActivated
事件handler receives所有激活事件。 Kind 属性指示激活事件的类型。此示例设置为处理Protocol激活事件。
因此,您可以在eventArgs.Uri.AbsolutePath
中获取参数。
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
var parm = eventArgs.Uri.AbsolutePath;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
}
}