【问题标题】:Extract Assembly Version from DLL using Python使用 Python 从 DLL 中提取程序集版本
【发布时间】:2011-06-24 15:25:15
【问题描述】:

我正在尝试使用 python 从 DLL 中提取一些版本信息。我读了这个问题: Python windows File Version attribute

这很有帮助,但我还需要从 DLL 中获取“程序集版本”。当我右键单击并查看版本选项卡时,它就在那里,但不确定我如何用 python 提取它。

在此页面上: http://timgolden.me.uk/python/win32_how_do_i/get_dll_version.html

蒂姆·戈尔登说:

你可以使用稍微凌乱的 演示中的语言相关代码 pywin32 自带的 在它下面的框中的字符串。

有人可以指出可能有用的示例吗?我查看了 win32api 目录,但没有什么明显的。我会在那里找到解决方案吗?

【问题讨论】:

    标签: python windows file-attributes versioninfo


    【解决方案1】:

    如果不想引入Python.Net的依赖,也可以直接使用win32 api:

    from win32api import GetFileVersionInfo, LOWORD, HIWORD
    
    def get_version_number (filename):
       info = GetFileVersionInfo (filename, "\\")
       ms = info['FileVersionMS']
       ls = info['FileVersionLS']
       return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls)
    

    来源:http://timgolden.me.uk/python/win32_how_do_i/get_dll_version.html

    【讨论】:

    • 这需要pywin32 我相信
    【解决方案2】:

    我不确定您是否可以通过使用本机代码获得此信息。获取程序集信息的常用方法是运行 .Net 代码(例如 C#)。所以我猜为了能够从 python 做同样的事情,你需要运行一些 .Net python 解释器。例如见http://pythonnet.github.io/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 2013-02-21
      • 1970-01-01
      • 2014-10-27
      • 1970-01-01
      相关资源
      最近更新 更多