using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows.Forms; namespace ZLPlugin_LisPacs_MR_YJMZ { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #region 控制程序只能打开一次 检测进程中是否存在有不同pid、相同程序名的; Process process = Process.GetCurrentProcess(); if (Process.GetProcesses().Any(s => s.ProcessName == process.ProcessName && (!s.Id.Equals(process.Id)))) { MessageBox.Show("程序已打开,请查看任务栏图标或托盘处!"); return; } #endregion Application.Run(new Form1()); } } }