[STAThread]
static void Main(string[] args)
{
bool isFirst;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "WindowAppTest", out isFirst);
//这里的myApp是程序的标识,建议换成你的程序的物理路径,这样的话如果在一个操作系统中这个标志不会和其它程序冲突
if (!isFirst)
{
MessageBox.Show("Exist");
Environment.Exit(1);//实例已经存在,退出程序
}
else
{
Application.Run(new Form1());
}
}