Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Aug 22, 2024
1 parent b5c286a commit 2ad7ebb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions JL.Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime;
using System.Windows;
Expand Down Expand Up @@ -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");
}
}
}
}
Expand Down

0 comments on commit 2ad7ebb

Please sign in to comment.