资讯动态

C# WinForm窗体应用程序只能运行一个解决方案

发布时间:2026/10/31 6:30:40 来源:尧图企业网站定制
internal static class Program { /// summary /// 应用程序的主入口点。 /// /summary [STAThread] static void Main() { bool ret; System.Threading.Mutex mutex new System.Threading.Mutex(true, Application.ProductName, out ret); if (ret) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { MessageBox.Show(null, 有一个和本程序相同的应用程序已经在运行请不要同时运行多个本程序。, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit();//退出程序 } } }

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价 →
↑