From 2ad7ebb1dfb84666e11a6e344b1ff7ff67cbe249 Mon Sep 17 00:00:00 2001 From: rampaa Date: Fri, 23 Aug 2024 00:07:13 +0300 Subject: [PATCH] Minor --- JL.Windows/App.xaml.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/JL.Windows/App.xaml.cs b/JL.Windows/App.xaml.cs index 8525017a..e0302c4f 100644 --- a/JL.Windows/App.xaml.cs +++ b/JL.Windows/App.xaml.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.Diagnostics; using System.Runtime; using System.Windows; @@ -39,11 +40,21 @@ private bool IsSingleInstance() for (int i = 0; i < processes.Length; i++) { Process process = processes[i]; - if (currentProcess.Id != process.Id && process.MainModule?.FileName == Environment.ProcessPath) + if (currentProcess.Id != process.Id) { - WinApi.RestoreWindow(process.MainWindowHandle); - Shutdown(); - return false; + try + { + if (process.MainModule?.FileName == Environment.ProcessPath) + { + WinApi.RestoreWindow(process.MainWindowHandle); + Shutdown(); + return false; + } + } + catch (Win32Exception e) + { + Utils.Logger.Information(e, "Couldn't get the path of the process, probably because it has a higher integrity level than this instance of JL"); + } } } }