[STAThread]
static void Main()
{
bool createdNew = false;
Mutex mutex = new Mutex(true, “CSharpHowTo_SingleInstanceApp”,
out createdNew);
if (createdNew)
{
//没有运行实例
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show( “You can only run a single instance of this app!”);
}
}