获取当前活动会话的所有进程 [英] Get all process of current active session

查看:278
本文介绍了获取当前活动会话的所有进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题而开发的应用程序。我想访问仅在当前会话的所有进程。目前我使用过程类,但它会返回所有会话的所有进程。

I have a small problem while developing an application. I want to access all process of the current session only. Currently I am using Process class but it will return all process of all session.

请帮我获得当前活动会话的过程中只不是全部。

Please help me to get process of the current active session only not all.

帮助解决问题需要的。

推荐答案

这会给你所用相同的sessionID运行为
中的当前过程的过程的运行列表。 。我认为这是你想要的。

This will give you a list of the process running that are running with the same sessionID as the current process. I think that is what you want.

Process[] runningProcesses = Process.GetProcesses();
var currentSessionID = Process.GetCurrentProcess().SessionId;

Process[] sameAsthisSession = (from c in runningProcesses where c.SessionId == currentSessionID select c).ToArray();

foreach (var p in sameAsthisSession)
{
   Trace.WriteLine(p.ProcessName); 
}

这篇关于获取当前活动会话的所有进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆