在“Program.cs”中添加以下代码:
[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool blnIsRunning; Mutex mutexApp = new Mutex(false, Assembly.GetExecutingAssembly().FullName, out blnIsRunning); if (!blnIsRunning) { MessageBox.Show("Is Running!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Application.Run(new Form1()); }
测试结果:
原文地址:https://www.cnblogs.com/jizhiqiliao/p/10768085.html
时间: 2024-11-13 13:54:53