使用Mutex。上面使用GetProcessByName的示例之一有很多警告。这是一篇关于该主题的好文章:
http://odetopre.com/Blogs/scott/archive/2004/08/20/401.aspx
[STAThread]static void Main() { using(Mutex mutex = new Mutex(false, "Global\" + appGuid)) { if(!mutex.WaitOne(0, false)) { MessageBox.Show("Instance already running"); return; } Application.Run(new Form1()); }}private static string appGuid = "c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9";


