如何阅读windows .exe文件版本?

时间:2021-09-17 06:29:56

I need to parse the file version and product version from windows exe and msi files.

我需要从windows exe和msi文件解析文件版本和产品版本。

Could you point me to the file specification or the library (preferably in Java) that does that?

你能指点我的文件规范或库(最好用Java)吗?

UPDATE:

It turns out I cannot use winapi, as the code needs to run on linux as well...

事实证明我不能使用winapi,因为代码需要在linux上运行...

2 个解决方案

#1


You could use GetFileVersionInfoSize and GetFileVersionInfo functions to get file version and product version. I'm not guru in Java but as far as I know there is the possibility to use WinAPI functions.

您可以使用GetFileVersionInfoSize和GetFileVersionInfo函数来获取文件版本和产品版本。我不是Java的大师,但据我所知,有可能使用WinAPI函数。

#2


I have a Delphi program which can analyze PE/NE headers in Windows EXE files - but not right here. I think it can be ported to Java easily as it does a binary analysis of the files.

我有一个Delphi程序,可以分析Windows EXE文件中的PE / NE头 - 但不是就在这里。我认为它可以轻松移植到Java,因为它可以对文件进行二进制分析。

Of course, using a JNA calls to Windows API could do the trick on Windows.

当然,使用JNA调用Windows API可以在Windows上实现这一目的。

Edit: I found it, but there are some minor glitches:

编辑:我找到了,但有一些小问题:

  • The original aim of the program was to extract resources from EXE (PE/NE) files, as at the time the available resource editors only worked with the PE format (NE is used by Win3.1)
  • 该程序的最初目的是从EXE(PE / NE)文件中提取资源,因为可用资源编辑器仅使用PE格式(Win3.1使用NE)

  • The UI does not display the version info, but the record structure is there for it
  • UI不显示版本信息,但记录结构就在那里

  • The UI is entirely in Hungarian, I can provide translation if needed
  • 用户界面完全是匈牙利语,如果需要,我可以提供翻译

  • Some of the code comments are in Hungarian, except some record structure descriptions, which are in English
  • 一些代码注释是匈牙利语,除了一些英文记录结构描述

  • I don't know if it compiles or not by its own today.
  • 我今天不知道它是否自己编译。

  • The ZIP includes a compiled Win32 RESXPLOR.EXE
  • ZIP包含一个已编译的Win32 RESXPLOR.EXE

  • The code has some buffer overrun bugs here or there - should be easily to fix it in Java
  • 代码在这里或那里有一些缓冲区溢出错误 - 应该很容易用Java修复它

#1


You could use GetFileVersionInfoSize and GetFileVersionInfo functions to get file version and product version. I'm not guru in Java but as far as I know there is the possibility to use WinAPI functions.

您可以使用GetFileVersionInfoSize和GetFileVersionInfo函数来获取文件版本和产品版本。我不是Java的大师,但据我所知,有可能使用WinAPI函数。

#2


I have a Delphi program which can analyze PE/NE headers in Windows EXE files - but not right here. I think it can be ported to Java easily as it does a binary analysis of the files.

我有一个Delphi程序,可以分析Windows EXE文件中的PE / NE头 - 但不是就在这里。我认为它可以轻松移植到Java,因为它可以对文件进行二进制分析。

Of course, using a JNA calls to Windows API could do the trick on Windows.

当然,使用JNA调用Windows API可以在Windows上实现这一目的。

Edit: I found it, but there are some minor glitches:

编辑:我找到了,但有一些小问题:

  • The original aim of the program was to extract resources from EXE (PE/NE) files, as at the time the available resource editors only worked with the PE format (NE is used by Win3.1)
  • 该程序的最初目的是从EXE(PE / NE)文件中提取资源,因为可用资源编辑器仅使用PE格式(Win3.1使用NE)

  • The UI does not display the version info, but the record structure is there for it
  • UI不显示版本信息,但记录结构就在那里

  • The UI is entirely in Hungarian, I can provide translation if needed
  • 用户界面完全是匈牙利语,如果需要,我可以提供翻译

  • Some of the code comments are in Hungarian, except some record structure descriptions, which are in English
  • 一些代码注释是匈牙利语,除了一些英文记录结构描述

  • I don't know if it compiles or not by its own today.
  • 我今天不知道它是否自己编译。

  • The ZIP includes a compiled Win32 RESXPLOR.EXE
  • ZIP包含一个已编译的Win32 RESXPLOR.EXE

  • The code has some buffer overrun bugs here or there - should be easily to fix it in Java
  • 代码在这里或那里有一些缓冲区溢出错误 - 应该很容易用Java修复它