Get DLL names from running process, possible?

2019-01-26 22:23发布

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.

标签: c# dll process
1条回答
甜甜的少女心
2楼-- · 2019-01-26 23:15

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.

查看更多
登录 后发表回答