//获取当前进程名称
string strProcessName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
//在所有已启动的进程中查找需要的进程;
Process[] temp = Process.GetProcessesByName(strProcessName);
//检查进程是否已经启动,已经启动则显示报错信息退出程序。
if (temp .Length > 1)
{
//提示用户进程已经启动
MessageBox.Show("程序已经启动!!!");
//退出当前进程
Environment.Exit(1);
}
C#避免程序重复启动
于 2023-12-11 16:56:59 首次发布