Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

delphi - change version number at build time

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Include a line like

{$R 'version.res'}

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'}

to have the IDE build it automatically for you.

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"
   VALUE "FileVersion", "9999.9999.99.18048"
   VALUE "LegalCopyright", "Copyright "
   VALUE "ProductName", "Product Name"
   VALUE "ProductVersion", "9999.9999.99.18048"
   VALUE "Homepage", "http://www.mydomain.com"
  }
 }
}

For more information, please refer to MSDN on the VERSIONINFO structure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...