private bool IsRunning(string prcName)
{
return (Process.GetProcessesByName(prcName).Length > 1) ? true : false;
}
{
return (Process.GetProcessesByName(prcName).Length > 1) ? true : false;
}
调用
代码
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();
}
}