第一种方法:
private static void GetCheckProcess()
{
bool createNew;
using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew))
{
if (createNew)
{
Application.Run(new ManagerComputer());
}
}
}
第二种方法:
string filename = Process.GetCurrentProcess().MainModule.FileName;
filename = System.IO.Path.GetFileNameWithoutExtension(filename);
Process[] pro = Process.GetProcessesByName(filename);
if (pro.Length == 0)
{
Application.Run(new ManagerComputer());
}