Get DLL names from a running process, maybe?

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

I need to "connect" to this process via its name or PID and get the DLL names it uses, if possible.

Sincerely.

+2


source to share


1 answer


Yes it is possible. You can use the class Process

. It has a property Modules

that lists all loaded modules.

For example, to display all processes and all modules on 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);
    }
}

      

You can of course check Process.Id

for the PID you would like, etc.



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

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

Note. This code can break certain system processes that you will not have access to.

+5


source







All Articles