在编译时如何知道DLL版本? [英] How do I know the DLL version, in compile time?

查看:213
本文介绍了在编译时如何知道DLL版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的项目是VC2010。我在这个项目中使用了一个dll。我注册并使用此Dll的.tlb文件。

Hi,
My project is with VC2010 . I use from a dll in this project. i register and use ".tlb" file of this Dll.

#import "C:\Windows\System32\MyDll.tlb" raw_interfaces_only





当我编译项目时,如何确定在我的系统中注册的当前dll的版本?



我想:

exe日志,exe编译的Dll版本用

我的意思是:

我想在编译时检查Dll版本, (不是运行时!!!)

我想在关于对话框的静态框中显示编译时间版本。



< b>我尝试了什么:





How do i determine the version of current dll, that is registerd in my system, when i'm compiling the project?

I want:
the exe logs, the version of Dll that exe is compiled with that
I mean:
I want to check Dll Version in compile time, (not runtime!!!)
I want to show "compile time version", in a Static box in about dialog.

What I have tried:

I want to show "compile time version" of Dll, in a Static box in about dialog.

推荐答案

您必须创建一个用户定义的构建步骤,以便在编译之前使您的应用程序可以使用此信息。请参阅了解自定义构建步骤和构建事件(VS 2010) [ ^ ] 。



一个可能的解决方案是编写一个批处理/命令文件,从DLL获取版本字符串并创建一个包含单行的头文件,其中包含版本的定义串。你的about box对话框源文件可以包含这个头文件。



要从DLL获取版本,你需要一个命令行工具。一种解决方案是使用PowerShell和

You have to create a user defined build step that makes this informatiomn available to your application before compiling. See Understanding Custom Build Steps and Build Events (VS 2010)[^].

A possible solution would be writing a batch / command file that gets the version string from the DLL and creates a header file containing a single line with the definition for the version string. Your about box dialog source file can the inlcude this header file.

To get the version from the DLL you need a command line tool. One solution is using the PowerShell with
(Get-Item path-to-dll).VersionInfo.FileVersion



另一个解决方案是使用 Sigcheck [ ^ ]实用程序。



或者编写我们自己的实用程序,使用 GetFileVersionInfo函数(Windows) [ ^ ]并创建头文件。


Another solution is to use the Sigcheck[^] utility from the SysInternal tools.

Or write our own utility that reads the information using the GetFileVersionInfo function (Windows)[^] and creates the header file.


这篇关于在编译时如何知道DLL版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆