.net 控制只允许运行一个应用程序
Process[] p = Process.GetProcesses();
int processCount = 0;
foreach (Process p1 in p)
{
if (p1.ProcessName.Trim() == "程序名")
{
processCount = processCount + 1;
}
}
if (processCount > 1)
{
MessageBox.Show("程序已启动");
Application.Exit();
return;
}