C# 限制系统重开
private bool IsRunning(string prcName)
{
return (Process.GetProcessesByName(prcName).Length > 1) ? true : false;
}
{
return (Process.GetProcessesByName(prcName).Length > 1) ? true : false;
}
调用
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
private void FrmMain_Load(object sender, EventArgs e)
{
if (IsRunning("CleanFileServer") == true)
{
MessageBox.Show("对不起,本系统已在运行!\n.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Dispose();
return;
}
else
{
ReadIp();
StartListen();
}
}
{
if (IsRunning("CleanFileServer") == true)
{
MessageBox.Show("对不起,本系统已在运行!\n.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Dispose();
return;
}
else
{
ReadIp();
StartListen();
}
}