如何实现:如果一个程序已经运行,再次运行的时候,激活并显示程序的窗口
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 myform = new Form1();
bool not_created;
Mutex m = new Mutex(true, "last ", out not_created);
if (not_created)
{
Application.Run(myform);
m.ReleaseMutex();
}
else
{
try
{
//用了n多种方法就是不成功
//myform.Show();
//myform.Activate();
//myform.Focus();
//myform.BringToFront();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}