从运行进程获取DLL名称可能吗? [英] Get DLL names from running process, possible?

查看:140
本文介绍了从运行进程获取DLL名称可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从正在运行的进程中获取DLL名称的方法,不幸的是,如果我表达的不好,就可以了。

I'm seeking for a way to get DLL names from a running process, sorry if I'm poorly expressing myself though.

我需要连接通过它的名称或PID进行此过程,并检索其使用的DLL名称,如果可能的话。

I need to "connect" to this process via it's name or PID and retrieve the DLL names that it's using if that's possible.

请问。

推荐答案

是的,这是可能的。您可以使用进程类。它有一个 Modules 属性,列出所有加载的模块。

Yes it is possible. You can use the Process class. It has a Modules property that lists all the loaded modules.

例如,列出所有进程和所有模块到控制台:

For example, to list all processes and all modules to the console:

Process[] processes = Process.GetProcesses();

foreach(Process process in processes) {
    Console.WriteLine("PID:  " + process.Id);
    Console.WriteLine("Name: " + process.Name);
    Console.WriteLine("Modules:");

    foreach(ProcessModule module in process.Modules) {
        Console.WriteLine(module.FileName);
    }
}

您当然可以检查对于您想要的PID的Process.Id

有关更多信息,请查看此类的文档: -

For more information check out the documentation for this class:-

http:// msdn .microsoft.com / en-us / library / system.diagnostics.process.aspx

注意:此代码可能会对某些系统感到不安您将无权访问的进程。

这篇关于从运行进程获取DLL名称可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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