简体   繁体   English

使用C#检索完整的进程列表

[英]Retrieve a complete processes list using C#

I am trying to write a C# program to retrieve a complete process list. 我试图编写一个C#程序来检索完整的进程列表。 However I find that an application open a window but I don't see it in the process tab of Windows task manager, I see it in task tab. 但是我发现一个应用程序打开了一个窗口,但在Windows任务管理器的“进程”选项卡中没有看到它,在任务选项卡中却看到了它。 In addition, I also cannot get its information using my C# code. 另外,我也无法使用C#代码获取其信息。

static void showProcesses()
{
    Process[] procs = Process.GetProcesses();

    foreach (Process proc in procs)
    {
        Console.WriteLine(proc.ProcessName);
    }
}

I browsed many forums but I can only find the methods to hide a process, and I don't find any method for showing hidden processes. 我浏览了许多论坛,但我只能找到隐藏进程的方法,而找不到用于显示隐藏进程的任何方法。 Do anyone have idea how to retrieve hidden process information? 有谁知道如何检索隐藏的过程信息?

There are no hidden processes on Windows. Windows上没有隐藏的进程。 Only processes you do not have (security) rights to see. 仅您没有查看(安全)权限的进程。

A process running as an administrator (in Vista/Win7/Win2k8 would need to be elevated) will always be able to see all processes. 以管理员身份运行的进程(在Vista / Win7 / Win2k8中需要提升)将始终能够查看所有进程。

However, a console application that lists the processes may well exit before Task Manager's display refreshes, and thus won't be seen. 但是,列出进程的控制台应用程序很可能在刷新任务管理器的显示之前退出,因此不会被看到。 This is likely with a simple program even with update speed set to "high". 即使将更新速度设置为“高”,也可能使用简单的程序。

You need to keep your process around until Task manager has updated its display. 您需要保持流程不变,直到任务管理器更新了其显示。 The simplest way would be do add the following statements to the end of your Main method: 最简单的方法是将以下语句添加到Main方法的末尾:

Console.Write("Press ENTER to exit");
Console.ReadLine();

I'm not sure what you mean. 我不确定你是什么意思。 The code above lists the same number of processes as pslist . 上面的代码列出了与pslist相同数量的进程。 When you talk about methods to hide a process are you talking about root kits? 当您谈论隐藏进程的方法时,您是在谈论根套件吗? If so they usually work by changing how the list commands work. 如果是这样,它们通常通过更改列表命令的工作方式来工作。 Ie the processes are in fact being enumerated, but the info is not displayed to the user. 即实际上是在枚举过程,但不会向用户显示该信息。

it works just fine all you need is add : 它工作得很好,您需要添加:

Console.Write("Press ENTER to exit");
Console.ReadLine();

at the end or start project with ctrl + F5 在最后或使用Ctrl + F5开始项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM