#coding:utf-8

myPath="C:\\ime"


import os

from win32api import GetFileVersionInfo, LOWORD, HIWORD

def get_version_number (filename):
    try:
    	info = GetFileVersionInfo (filename, "\\")
    	ms = info['FileVersionMS']
    	ls = info['FileVersionLS']
    	return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls)
    except:
    	return 0,0,0,0
    
for root, dirs, files in os.walk(myPath):
    for file in files:
    	file = file.lower() # Convert .EXE to .exe so next line works
    	if (file.count('.exe') or file.count('.dll')): # Check only exe or dll files
    		fullPathToFile=os.path.join(root,file)
    		major,minor,subminor,revision=get_version_number(fullPathToFile)
		fstr = "%s.%s.%s.%s"%(major,minor,subminor,revision)
    		print "Filename: %s \t Version: %s.%s.%s.%s" % (file,major,minor,subminor,revision)

  

posted on 2016-05-09 14:32  小白闯天下  阅读(738)  评论(0编辑  收藏  举报