不得不感叹一下天下代码一大抄,到百度上一搜,结果都是如下的代码。
[STAThread]
static void Main()
{
//只允许运行一个程序
bool createNew;
System.Threading.Mutex mutex = new System.Threading.Mutex
(true, "Global\" + Application.ProductName, out createNew);
{
if (createNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("只允许运行一个程序!");
}
}
}
[STAThrea