/// <summary>
/// 获取正在运行的程序,没有运行的程序则返回null
/// </summary>
/// <returns></returns>
private static Process RunningInstance()
{
Process currentProcess = Process.GetCurrentProcess();
var processcollection = Process.GetProcessesByName(currentProcess.ProcessName.Replace(".vshost", "")).Where(a => a.Id != currentProcess.Id).ToList();
foreach (Process process in processcollection)
{
if (process.ProcessName == currentProcess.ProcessName)
{
return process;
}
}
return null;
}
标签:Process,process,ProcessName,C#,程序,currentProcess,重复,控制台,null
From: https://www.cnblogs.com/boxrice/p/16915597.html