/// <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; }