如何获得在Windows上运行的应用程序? [英] How to get running applications in windows?
问题描述
我怎样才能在Windows中当前运行的应用程序或前景的进程列表?
How can I get the list of currently running applications or foreground processes in Windows?
我的意思是有真正的一个窗口的应用程序。没有后台服务/进程。 我想访问同一个列表中的任务管理器显示,当我们打开它。
I mean the applications that have a window for real. Not the background services/processes. I want to access the same list a task manager shows when we open it.
有没有办法? 任何类型的解决方案是可接受的。无论是命令或.NET code或任何东西。我只是想获得该列表编程。
Is there a way? Any type of solution is acceptable. Either a command or a .NET code or anything. I just want to get that list programmatically.
是,即使可能吗?
我累了任务列表,但它给了我所有的服务和流程,甚至是背景的。
I tired tasklist but it gives me all the services and processes, even the background ones.
有没有逻辑,我可以实现?
Is there any logic I could implement?
推荐答案
这可以帮助:
Process[] processes = Process.GetProcesses();
foreach(Process p in processes)
{
if(!String.IsNullOrEmpty(p.MainWindowTitle))
{
listBox1.Items.Add(p.MainWindowTitle);
}
}
这篇关于如何获得在Windows上运行的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!