简体   繁体   English

如何列出 Python 进程加载的所有 dll?

[英]How to list all dlls loaded by a process with Python?

I want to list all the dlls loaded by a process, like this:我想列出一个进程加载的所有 dll,如下所示:

在此处输入图像描述

How could I get the information with Python on Windows?我如何在 Windows 上获取 Python 的信息?

Using the package psutil it is possible to get a portable solution! 使用psutil包可以获得便携式解决方案! :-) :-)

# e.g. finding the shared libs (dll/so) our python process loaded so far ...
import psutil, os
p = psutil.Process( os.getpid() )
for dll in p.memory_maps():
  print(dll.path)

Using listdlls : 使用listdlls

import os
os.system('listdlls PID_OR_PROCESS_NAME_HERE')

With pywin32 already installed do like:已经安装了pywin32时,请执行以下操作:

import win32api, win32process
for h in win32process.EnumProcessModules(win32process.GetCurrentProcess()):
    print(win32api.GetModuleFileName(h)

Use functions like win32api.GetFileVersionInfo() , .EnumResourceNames() ... on the dll paths to get dll attribute data.在 dll 路径上使用win32api.GetFileVersionInfo().EnumResourceNames() ... 等函数来获取 dll 属性数据。

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

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