Parcourir la source

增加程序只能同时打开一个的验证

SYL il y a 4 ans
Parent
commit
cd36fb6acb
1 fichiers modifiés avec 13 ajouts et 4 suppressions
  1. 13 4
      DWZB_Agv_Agreement/Program.cs

+ 13 - 4
DWZB_Agv_Agreement/Program.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
@@ -14,10 +15,18 @@ namespace DWZB_Agv_Agreement
         [STAThread]
         static void Main()
         {
-            Application.SetHighDpiMode(HighDpiMode.SystemAware);
-            Application.EnableVisualStyles();
-            Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new Form1());
+            _ = new Mutex(true, "DRM2", out bool canCreateNew);
+            if (canCreateNew)
+            {
+                Application.SetHighDpiMode(HighDpiMode.SystemAware);
+                Application.EnableVisualStyles();
+                Application.SetCompatibleTextRenderingDefault(false);
+                Application.Run(new Form1());
+            }
+            else
+            {
+                MessageBox.Show("³ÌÐòÒѾ­ÔËÐУ¡£¡");
+            }
         }
     }
 }