From 6896b32d9850186ad3d2fa6f48f142778fbad7f5 Mon Sep 17 00:00:00 2001 From: Josh Max Date: Tue, 13 Sep 2022 09:51:20 -0700 Subject: [PATCH] Only allow one instance of WinHideEx to run at a given time --- WinHideExGUI/Program.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/WinHideExGUI/Program.cs b/WinHideExGUI/Program.cs index 785fd63..47ccccb 100644 --- a/WinHideExGUI/Program.cs +++ b/WinHideExGUI/Program.cs @@ -1,16 +1,29 @@ using System; +using System.Threading; using System.Windows.Forms; +using WinHideExGUI.Properties; namespace WinHideExGUI { static class Program { + // Our mutex + private static Mutex mutex = null; + /// /// The main entry point for the application. /// [STAThread] static void Main() { + mutex = new Mutex(true, Resources.AppName, out bool createdNew); + + if (!createdNew) + { + MessageBox.Show("Another instance of the application is already running!"); + return; + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new CustomApplicationContext(new MainForm()));