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;
}
当前进程
最新推荐文章于 2022-11-07 16:41:47 发布