http://www.codeproject.com/Articles/32908/C-Single-Instance-App-With-the-Ability-To-Restore
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool onlyInstance = false;
Mutex mutex = new Mutex(true, "RedirectorConfigurationTool", out onlyInstance);
if (!onlyInstance)
{
MessageBox.Show("Only one instance can be lunched at the same time");
return;
}
else
{
Application.Run(new ConfigurationTool());
}
}
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool onlyInstance = false;
Mutex mutex = new Mutex(true, "RedirectorConfigurationTool", out onlyInstance);
if (!onlyInstance)
{
MessageBox.Show("Only one instance can be lunched at the same time");
return;
}
else
{
Application.Run(new ConfigurationTool());
}
}
做个快乐的自己。