您的位置:首页 > 其它

(小技巧六)只允许一个进程运行winform

2005-02-03 17:08 316 查看
static void Main()
// get the name of our process
string proc=Process.GetCurrentProcess().ProcessName;
// get the list of all processes by that name
Process[] processes=Process.GetProcessesByName(proc);
// if there is more than one process if (processes.Length > 1)
MessageBox.Show("Application is already running");
return;
} else
Application.Run(new Form1());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: