#说明:遍历rootdir目录下所有dll,导出每个dll依赖的dll信息到dstdir目录下
# 配合NotePad++打开所有txt,搜索,可快速定位到某dll被依赖的所有dll文件
import os
rootdir = 'C:/Users/xx/Desktop/release' #目录不能有空格,左斜杠,路径必须存在
dstdir = 'C:/Users/xx/Desktop/release/import/' #目录不能有空格,左斜杠,路径必须存在
def dll_import(path, name):
cmd1 = 'cd D:\Program Files (x86)\Microsoft Visual Studio 9.0\VC' #注意VS的路径
cmd2 = 'vcvarsall.bat'
cmd3 = 'dumpbin -imports ' + path + " > " + dstdir + name + ".txt"
cmd = r'"' + cmd1 + ' && ' + cmd2 + ' && ' + cmd3 + r'"'
os.system(cmd)
def dll_dependency(dir):
list = os.listdir(dir)
for i in range(0, len(list)):
path = os.path.join(dir, list[i])
if os.path.isfile(path):
if path.find(".dll") != -1:
(filepath, tempfilename) = os.path.split(path);
(shotname, extension) = os.path.splitext(tempfilename);
dll_import(path, shotname)
dll_dependency(rootdir)
环境:Python 3.5.0 VS 2008