Reputation: 35
I'm seeking for a way to get DLL names from a running process, sorry if I'm poorly expressing myself though.
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.
Regards.
Upvotes: 2
Views: 5313
Reputation: 29668
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.ProcessName);
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 might get upset for certain system processes which you will not have access permission to.
Upvotes: 6