views:

155

answers:

5

Hello, 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!

+1  A: 

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.

Eugene Mayevski 'EldoS Corp
+1  A: 

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.

Andrei K.
+6  A: 

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
 }

}
Michał Niklas
+1 for addressing the cause and not just dealing with the symptoms. It might be worth mentioning in your answer that for this to work in the IDE as well, you need to turn off "include version" in the project's options. Something the IDE will not allow you to do for dll projects, you may have to "hack" the dproj for that by hand.
Marjan Venema
+1  A: 

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.

Chris Thornton
+1  A: 

There is ChangeRes which seems to match your needs.

Uwe Raabe