From 2f9f33b985ffcc0a528311557af5e2d068037b84 Mon Sep 17 00:00:00 2001 From: Vesko Karaganev Date: Sun, 24 Mar 2024 07:32:08 +0000 Subject: [PATCH] Put back packaging support, but avoid expensive call --- FancyWM/Startup.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/FancyWM/Startup.cs b/FancyWM/Startup.cs index c3c04ee..c87f6ac 100644 --- a/FancyWM/Startup.cs +++ b/FancyWM/Startup.cs @@ -10,6 +10,7 @@ using FancyWM.Utilities; using System.Text; using System.Security.Principal; +using System.Runtime.InteropServices; namespace FancyWM { @@ -38,6 +39,29 @@ public static int Main(string[] args) } Directory.SetCurrentDirectory(fullPath); + bool isPackaged = false; + try + { + global::Windows.ApplicationModel.Package.Current.GetHashCode(); + isPackaged = true; + } + catch (Exception) + { + } + + if (isPackaged) + try + { + if (global::Windows.ApplicationModel.AppInstance.GetActivatedEventArgs() is global::Windows.ApplicationModel.Activation.CommandLineActivatedEventArgs storeAppArgs) + { + args = storeAppArgs.Operation.Arguments.Split(); + } + } + catch (COMException) + { + // not a store packaged app + } + if (args.Contains("--action")) { ExecuteAction(args[args.IndexOf("--action") + 1]);