| C#如何防止程序被重复打开
					当前位置:点晴教程→知识管理交流
					
					→『 技术文档交流 』
					
				 
 在程序的program.cs中,更改如下: namespace form_repeat_open {     static class Program     {         /// <summary>         /// 应用程序的主入口点。         /// </summary>         [STAThread]         static void Main()         {             bool createNew;             using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew))             {                 if (createNew)                 {                     Application.EnableVisualStyles();                     Application.SetCompatibleTextRenderingDefault(false);                     Application.Run(new Form1());                     mutex.ReleaseMutex();                 }                 else                 {                     MessageBox.Show("本程序已打开,禁止重复打开本程序!", "重复打开", MessageBoxButtons.OK, MessageBoxIcon.Warning);                     Thread.Sleep(500);                     System.Environment.Exit(1);                 }             }         }     } } 该文章在 2021/3/29 22:59:01 编辑过 | 关键字查询 相关文章 正在查询... |