修改版本号 [英] change version number at build time
问题描述
我需要将我的delphi项目的版本设置为与另一个项目(不是delphi)相同,作为构建脚本的一部分。有没有办法通过IDE来控制版本号,例如编译器的命令行参数或类似的?谢谢
I need to set the version of my delphi project to be the same as another project (not delphi) as part of a build script. Is there a way to control the version number without going thru the IDE, for example command line param of the compiler or something like that? Thanks
推荐答案
包含一行如
{$R 'version.res'}
在您的项目中。并创建一个版本信息的version.rc文件。您将不得不使用brcc32在旧的Delphi版本中自行构建资源。在更新的Delphi版本中,您可以使用
in your project. And create a version.rc file with your version information. You will have to build the resource yourself in older Delphi versions using brcc32. In newer Delphi versions you can use
{$R 'version.res' 'version.rc'}
让IDE自动为您建立。
to have the IDE build it automatically for you.
最简单的version.rc看起来像:
The simplest version.rc would look something like:
1 VERSIONINFO
FILEVERSION 9999, 9999, 99, 18048
PRODUCTVERSION 9999, 9999, 99, 18048
FILEOS 0x00000004L // comment: VOS_WINDOWS32
FILETYPE VFT_APP
{
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 0x4E4 // comment: 0x4E4 = 1252
}
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "Company Name\0"
VALUE "FileVersion", "9999.9999.99.18048\0"
VALUE "LegalCopyright", "Copyright \0"
VALUE "ProductName", "Product Name\0"
VALUE "ProductVersion", "9999.9999.99.18048\0"
VALUE "Homepage", "http://www.mydomain.com\0"
}
}
}
有关详细信息,请参阅MSDN上的 VERSIONINFO 结构。
For more information, please refer to MSDN on the VERSIONINFO structure.
这篇关于修改版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!