/// <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("应用程序已经启动!");
}