[C#] public static Process RunningInstance() { Process current = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName (current.ProcessName); //查找相同名稱的進程 foreach (Process process in processes) { //忽略當前進程 if (process.Id != current.Id) { //確認相同進程的程序運行位置是否一樣. if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName) { //Return the other process instance. return process; } } } //No other instance was found, return null. return null; }