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

Categories

0 votes
1.1k 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...