8

Background

Upto RS10.3 I used to use Andreas Hausladen DDevExtensions to set my version number in my project sources to be the same for all modules (bpl's/exe), but unfortunately Andreas has stopped updating his tool for RS10.4 and later.

So I am looking for more comfortable ways to set a version number in my app modules than applying multi-file changes to all dproj files with NotePad++.

But... On the other side I do want to keep specific information (like file description etc) specific to the module file.

What I also would like but isnt really a requirement is to have my (c) notice, and other shared info to be centralized in a single file (preferably .rc) as well.

It is not a problem to drop the version info from the dproj files (which are a pain to maintain anyway) and have a specific .rc file for each module instead.

Another advantage would be that having one central version number and (c) file is also a lot better in svn change management since I don't have to commit each and every .dproj file because of the version/build number change.

Investigation

(To be updated as we go along) I Checked out

But those solutions are not really what I am looking for; I am not looking for scripts but a source file/project file way to accomplish my task.

So here's the Q

How can I have one single .rc file containing my version number and use it in other .rc files containing specific version info

H.Hasenack
  • 1,094
  • 8
  • 27

1 Answers1

9

Ah I didn't expect it to be this simple... I Created two .rc files, one with the shared info as #defines SharedVersionDefs.rc:

#define VER_MAJ 1
#define VER_MIN 2
#define VER_SUB 3
#define VER_BUILD 8

#define VER_FILEVERSION             VER_MAJ,VER_MIN,VER_SUB,VER_BUILD
#define VER_FILEVERSION_STR         ""VER_MAJ,VER_MIN,VER_SUB,VER_BUILD"\0"

// in my app file and product version are the same
#define VER_PRODUCTVERSION          VER_MAJ,VER_MIN,VER_SUB,VER_BUILD
#define VER_PRODUCTVERSION_STR      ""VER_MAJ,VER_MIN,VER_SUB,VER_BUILD"\0"

#define VER_COMPANYNAME_STR "MyCompany\0"
#define VER_LEGALCOPYRIGHT_STR "(c) 2020 "VER_COMPANYNAME_STR"\0"

And one specific file (which would re-appear for each module with different names and contents) SpecificVersion.rc:

/* Use the shared version info from a central file */
#include "SharedVersionDefs.rc"


#ifndef DEBUG
#define VER_DEBUG                   0
#else
#define VER_DEBUG                   VS_FF_DEBUG
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION

BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName",      VER_COMPANYNAME_STR
            VALUE "FileDescription",  "Specific file description"
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     "Specific internal name"
            VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
            VALUE "ProductName",      "LCCAMQM"
            VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
        END
    END

    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END

Just had to create these 2 files, set version info in the delphi dproj file to OFF, and then add the specific .rc file to the module's dproj where I want it to appear, in this case a minor delphi project:

program VersionInfoTest;

{$R 'SpecificVersion.res' 'SpecificVersion.rc'}

uses
  Vcl.Forms,
  uMain in 'uMain.pas' {frmMain},
  uVerinfo in 'uVerinfo.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;
end.

And I verified this worked.

ATTENTION: Due to RSP-13486 you are required to add the .rc file to the .dproj file as well. Just drag-and-drop in in there using the IDE.

More info regarding the .rc files and examples can be found on MSDN

H.Hasenack
  • 1,094
  • 8
  • 27
  • For me this fails when one of the values is more than a single digit. – FredS Jul 01 '20 at 02:00
  • @FredS That's strange, In my application the build nr (4 digits bij now) comes through just fine. (For de VER_BUILD define) – H.Hasenack Jul 01 '20 at 06:39
  • When I open the RES file in Visual Studio I see both entries in the "StringFileInfo" for FileVersion and ProductVersion as `ँ`. The Properties dialog shows FileVersion correctly but since this entry in "StringFileInfo" is NOT required I think it simply defaults. ProductVersion shows as `ँ` in properties.. – FredS Jul 01 '20 at 14:34
  • @FredS This could very well be, didnt try. I was mostly interested in storing the version # in a single file for my " gazillion#" of bpl's – H.Hasenack Jul 01 '20 at 20:13
  • @FredS I examine my output DLL's, BPL's and EXE's with respect to all resources with http://www.angusj.com/resourcehacker/ . If I find the time I'll check it out. I didnt check the .res files themselves actually. – H.Hasenack Jul 01 '20 at 21:19
  • 1
    It appears brcc is buggy regarding the defines. You cannot re-use the VER_MAJ etc defines in the VER_FILEVERSION_STR, but have to define it as a string directly (thus replicating the version number) – H.Hasenack Aug 26 '20 at 10:17