C# WinForm 如何实现程序重启?(加了一个进程判断,每次重启都弹出提示框)
//检查同一位置Processcurrent=Process.GetCurrentProcess();Process[]processes=Process.GetProc...
//检查同一位置
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
foreach (Process process in processes)
{
if (process.Id != current.Id)
{
if (process.MainModule.FileName == current.MainModule.FileName)
{
MessageBox.Show("程序已经运行!\n如果未看见窗口,请点击右下角任务栏中的图标。", "农业智能控制", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
} 展开
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(current.ProcessName);
foreach (Process process in processes)
{
if (process.Id != current.Id)
{
if (process.MainModule.FileName == current.MainModule.FileName)
{
MessageBox.Show("程序已经运行!\n如果未看见窗口,请点击右下角任务栏中的图标。", "农业智能控制", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询