本文实例讲述了C#简单实现防止多个程序运行的方法。分享给大家供大家参考,具体如下:
/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]static void Main(){ System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName); if (ps.Length <= 1) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } else { return; }}