在program的mian方法中添加如下代码:
static void Main() { bool started = true; using (new Mutex(true, Assembly.GetExecutingAssembly().FullName, out started)) { if (!started) { MessageBox.Show("程序已启动!"); System.Environment.Exit(0); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmLogin()); } } }