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; } [VB.NET]