转储 Windows DLL 版本的命令行工具?
我需要一个命令行工具来转储标准 Windows DLL 版本信息,以便我可以通过 bash 脚本 (Cygwin) 对其进行处理。
作为一名 Java 开发人员,我不太习惯 Microsoft 开发工具(尽管我对 Microsoft Visual Embedded C++ 4.0 和 Microsoft Visual Basic 6.0 有一点经验)。
适当的工具似乎是 mt.exe,如 如此说明。 然而,我发现获得这个小应用程序的唯一机会是下载 适用于 Windows Server 2008 和 .NET Framework 的 Windows SDK。 我不敢相信这是唯一的方法。
我还在网上找到了一个名为 PEView 的小应用程序,但它显示的内容太多(而且没用)就我而言)信息,它不是命令行应用程序。
Cygwin 中捆绑的标准 objdump 也可以转储有关 DLL 文件的一些信息,但我看不到转储 DLL 版本的选项。 请注意,该工具(使用 -p 选项)转储的 MajorImageVersion、MinorImageVersion 和其他字段与自己的 DLL 版本无关。
关于该做什么还有其他选择吗? 也许我错过了一些重要的 objdump 选项? mt.exe 是我唯一的选择吗? 如果是这种情况,是否可以从 Windows SDK 中单独获取它?
I need a command line tool to dump standard Windows DLL version info so I can process it by means of a bash script (Cygwin).
As a Java developer I am not very used to Microsoft development tools (though I have a little bit of experience with Microsoft Visual Embedded C++ 4.0 and Microsoft Visual Basic 6.0).
The appropriate tool seems to be mt.exe, as stated on SO. However the only chance I have found to get this little application is to download a 1.29 GB ISO of the Windows SDK for Windows Server 2008 and .NET Framework. I can not believe this is the only way to do it.
I have also found a little application on the Internet called PEView, but it displays too much (and useless in my case) information and it is not a command line application.
Standard objdump bundled inside Cygwin can also dump some information about the DLL files, but I can not see the option to dump DLL version. Note that MajorImageVersion, MinorImageVersion and other fields dumped by this tool (with -p option) are not related to own DLL version.
Any alternatives about what to do? Maybe I missed some important objdump option? Is mt.exe my only choice? If this is the case, is it possible to get it separately from Windows SDK?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
您可以使用 PowerShell 来获取所需的信息。
默认情况下,这将显示 ProductVersion 和 FileVersion
但完整的VERSIONINFO 可用。 即返回评论
You can use PowerShell to get the information you want.
By default this will display ProductVersion and FileVersion
But the full VERSIONINFO is available. I.e. to return Comments
使用 Microsoft Sysinternals Sigcheck。
此示例仅输出版本:
解压后的 sigcheck.exe 仅 228 KB。
Use Microsoft Sysinternals Sigcheck.
This sample outputs just the version:
Unpacked sigcheck.exe is only 228 KB.
您可以编写 VBScript 脚本来获取文件版本信息:
VersionInfo.vbs
您可以从命令行调用它,如下所示:
You can write a VBScript script to get the file version info:
VersionInfo.vbs
You can call this from the command line like this:
或者您可以自己构建一个。 打开VS,创建一个新的控制台应用程序。 创建一个不支持 ATL 或 MFC 的简单项目,选中 stdafx 选项,但不选中“空项目”并将其命名为 VersionInfo。
您将得到一个包含 2 个文件的简单项目:VersionInfo.cpp 和 VersionInfo.h
打开 cpp 文件并将以下内容粘贴到其中,然后编译。 您将能够运行它,第一个参数是完整的文件名,它将根据版本资源块打印出“Product:5.6.7.8 File:1.2.3.4”。 如果没有版本资源,它将返回 -1,否则返回 0。
使用 dll CRT 编译为 8k 二进制文件,所有内容均静态链接为 60k(在 C++ 选项中设置,将“代码生成页面,运行时选项”更改为“/MT”) ”)
HTH。
附言。 如果您不想使用 Visual Studio,它仍然会使用任何 C++ 编译器进行编译(交叉手指),但您几乎肯定必须更改 #pragma - 只需在链接器设置中指定该 lib,pragma 的只是自动链接到该库的简写。
or you can build one yourself. Open VS, create a new console application. Create a simple project with no ATL or MFC support, leave the stdafx option checked but do not check 'empty project' and call it VersionInfo.
You'll get a simple project with 2 files: VersionInfo.cpp and VersionInfo.h
Open the cpp file and paste the following into it, then compile. You'll be able to run it, first argument is the full filename, it'll print out "Product: 5.6.7.8 File: 1.2.3.4" based on the Version resource block. If there's no version resource it'll return -1, otherwise 0.
Compiles to an 8k binary using the dll CRT, 60k with everything linked statically (set in the C++ options, change "Code Generation page, Runtime options" to "/MT")
HTH.
PS. If you don't want to use Visual Studio, it'll still compile using any c++ compiler (fingers crossed), but you'll almost certainly have to change the #pragma - just specify that lib in the linker settings instead, the pragma's just a shorthand to automatically link with that library.
您还可以查看 filever.exe,它可以作为 Windows XP SP2 支持工具 包 - 仅下载 4.7MB。
You can also look at filever.exe, which can be downloaded as part of the Windows XP SP2 Support Tools package - only 4.7MB of download.
使用 Powershell 可以使用以下命令从任何 dll 或 exe 中获取版本字符串,即 2.3.4
在 Windows 10 上测试
Using Powershell it is possible to get just the Version string, i.e. 2.3.4 from any dll or exe with the following command
Tested on Windows 10
Systernals 的 listdlls 工具可能可以完成这项工作: http://technet.microsoft.com /en-us/sysinternals/bb896656.aspx
The listdlls tools from Systernals might do the job: http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx
此函数使用 Cygwin bash(实际的 r-click-properties-info)返回任何文件的 ntfs Windows 文件详细信息
将文件路径传递给 finfo(),可以是 unix 路径、dos 路径、相对或绝对路径。 该文件被转换为绝对 nix 路径,然后检查它是否实际上是常规/现有文件。 然后转换成windows绝对路径并发送给“wmic”。 然后神奇的是,您就可以在终端中获得 Windows 文件详细信息。 用途:cygwin、cygpath、sed 和 awk。 需要 Windows WMI“wmic.exe”才能运行。 输出经过校正,以便轻松...
This function returns the ntfs Windows file details for any file using Cygwin bash (actual r-click-properties-info) to the term
Pass the files path to finfo(), can be unix path, dos path, relative or absolute. The file is converted into an absolute nix path, then checked to see if it is in-fact a regular/existing file. Then converted into an absolute windows path and sent to "wmic". Then magic, you have windows file details right in the terminal. Uses: cygwin, cygpath, sed, and awk. Needs Windows WMI "wmic.exe" to be operational. The output is corrected for easy...
对于某些 DLL,我使用 .rsrc。 使用 objdump -s -j .rsrc zlib1.dll :
For some DLLs I found version info manually with
objdump
in .rsrc. Withobjdump -s -j .rsrc zlib1.dll
:CodeProject 有一个名为“ShowVer”的命令行应用程序:
ShowVer.exe 命令行 VERSIONINFO 显示程序
与往常一样,该应用程序附带一个 exe 和源代码 (VisualC++ 6)。
Out 输出所有可用的元数据:
在德国 Win7 系统上,user32.dll 的输出如下:
There is an command line application called "ShowVer" at CodeProject:
ShowVer.exe command-line VERSIONINFO display program
As usual the application comes with an exe and the source code (VisualC++ 6).
Out outputs all the meta data available:
On a German Win7 system the output for user32.dll is like this:
只需查看版本:
文件鼠标右键-> 属性-> 详细信息:
For just see version:
file mouse right click -> properties -> Details: