/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
// 只有一個實例運行
//聲明互斥體。
string info = "abcdefg"; <--關鍵是在這裏,用它來標識程序是否已經運行
Mutex mutex = new Mutex(false,info);
//判斷互斥體是否使用中。
bool RunExists = !mutex.WaitOne(0, false);
if (! RunExists )
Application.Run(new Form1());
else
MessageBox.Show("應用程序已經啓動!");
}