9
votes

I'm looking for a ready-to-use piece of code that would be able to read and modify Delphi .res files. The thing is that I need to create an application that will be compiling many Delphi projects at once (using the dcc32.exe file). However, it is necessary for me to change file version and language before compilation, and as far as I know, I have to modify the .res file to do that.

Have you come across any code that would give me an interface to .res files allowing me to modify the data contained in it? The thing is that I want to change only those two pieces of information keeping the rest unchanged. This is why I can't compile my own .res file based on a script.

An application executed from a command line would also be OK if it allows to be called with parameters and does what I need it to do.

Thank you very in advance!

5
Also you can vote for QC #70567 (do not store version information in the compiled .res file - to allow for easier manipulation), and QC #70564 (allow version informations to be set from the command line) - user160694

5 Answers

10
votes

If all you need is to add file version resource then create appver.rc file, compile it with brcc32 and in one of your app unit (for example appver.pas) add {$R appver.res} (as Marian noticed you must turn off Delphi project option to include version info).

I created command line programs that increase build numbers in .rc file, create new branch/tag in SVN with new version in branch name, compiles .rc to .res, and build application.

My .rc files with such info (Polish language) looks like:

#define IDR_VERSION1  1
IDR_VERSION1 VERSIONINFO LOADONCALL MOVEABLE DISCARDABLE IMPURE
FILEVERSION 7,28,7,17
PRODUCTVERSION 7,28,7,17
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0
{
 BLOCK "StringFileInfo"
 {
  BLOCK "041504E2"
  {
   VALUE "CompanyName", "xxx\0"
   VALUE "FileDescription", "yyy\0"
   VALUE "ProductName", "zzz\0"
   VALUE "FileVersion", "7.28.7.17\0"
   VALUE "ProductVersion", "7.28.7.17\0"
  }

 }

 BLOCK "VarFileInfo"
 {
  VALUE "Translation", 0x0415, 1250
 }

}
3
votes

For all things .res, look at Colin Wilson's "XN Resource Editor", for which he provides the source code: http://www.wilsonc.demon.co.uk/d10resourceeditor.htm And probably all you need is his resource utility library: http://www.wilsonc.demon.co.uk/d9resourceutils.htm I haven't used this source, but if I needed it, that's the first place I'd look. His resource editor is very useful, btw.

3
votes

There is ChangeRes which seems to match your needs.

2
votes

Check out sources:

http://code.google.com/p/gedemin/source/browse/trunk#trunk/Gedemin/Utility/IncVerRC

It is our utility which reads .RC file with version information and increments build number. We use it inside our build process. Here is an excerpt:

incverrc.exe ..\gedemin\gedemin.rc
"%delphi_path%\brcc32.exe" -fogedemin.res -i..\images gedemin.rc
"%delphi_path%\dcc32.exe" -b gedemin.dpr

The utility uses TIncVerRc class written by Chris Morris.

1
votes

Check Resource Tuner Console on www.heaventools.com. They position that product for tasks like yours. Also there's a free rcstamp tool on CodeProject.