如何获取任务管理器(非进程)中显示的应用程序列表 [英] How can I get list of Applications as shown in Task Manager (Not Processes)

查看:31
本文介绍了如何获取任务管理器(非进程)中显示的应用程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取当前使用 Windows 应用程序运行的应用程序的列表.

I am trying to obtain a list of the Applications currently running using a Windows Application.

    using System.Diagnostics;
    Process[] processes = Process.GetProcesses();
        List<string > listProc=new List<string>() ;
        foreach (Process p in processes)
        {
            listProc.Add(p.ProcessName );               
        }
        string joined = string.Join(",", new List<string>(listProc).ToArray());
        ScriptingObject.WriteLogMessage("List of Processes: " + joined , true);

我也试过这个:

    if (!String.IsNullOrEmpty(p.MainWindowTitle))
            {
                listProc.Add(p.MainWindowTitle);

            }

这些可以很好地列出 Windows 任务管理器列出的进程,但我如何查看应用程序选项卡下列出的应用程序?

These work fine listing the Processes listed by the Windows Task Manager, but how do I see the Applications listed under the Applications Tab?

第一个选项列出的进程比第二个多,如果我以管理员身份运行,我会看到更多进程,但我仍然没有看到任务管理器列出的所有我能看到的应用程序.

The first option lists more processes than the 2nd, and I see even more if I run as Administrator, but I am still not seeing all the Applications I can see listed by the Task Manager.

我认为我正在寻找的应用程序可能被描述为子窗口.

I think the Application I am looking for might be described as a Child Window.

推荐答案

Process[] processes = Process.GetProcesses();
List<string > listProc=new List<string>() ;
foreach (Process p in processes)
{
    if (p.MainWindowHandle.ToInt32()>0)
    {
        listProc.Add(p.MainWindowTitle);
    }               
}

这篇关于如何获取任务管理器(非进程)中显示的应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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