Set Delphi 7 project "Version Info" from code?
Asked Answered
S

5

12

Is it possible to set the "Version Info" settings from code? I'd like to set the version numbering and the value for the "Comments" property without using the project options dialog.

Scow answered 7/7, 2010 at 12:29 Comment(2)
Can you elaborate on this a bit? Do you really want to change the version of your EXE after compilation? Your application might get confused for some Mallware for doing that! Or do you want to change it just once at compile time? Or maybe immediately after compile time?Tepid
I dont't want to change it after the compilation. I only want set the values for compilation in code.Scow
A
10

Rather than editing the binary RES file that the IDE manages for you, you may find it easier to maintain a text RC file that contains the version-info resource. Write the resource-script file, and then include it in your project with a line like this:

{$R resources.res resources.rc}

You should remove the {$R *.RES} line from your project's DPR file, or else you'll get duplicate version resources. Do not use your project name as the name of your custom resource file; that name is reserved by the IDE.

The IDE-managed resource file also contains the project icon, so you'll need to include that in your resource script as well.

You can edit the resource script by hand, or you can write a program to edit it or regenerate it as one of your build steps.

Using a text resource script has the added side effect that it's easier to track changes to it in whatever source-control system you use, like CVS.

Acetal answered 7/7, 2010 at 13:23 Comment(8)
+1 We're currently using version info in the .bdsproj and .res files, and it's a nightmare. It makes merging troublesome. We've got a branch creator that changes the version info and checks back into svn, so that's not a problem, but we pay dearly when we try to merge later. 99% of the changes are the .bdsproj and .res files! We're going to move to a .rc approach instead.Eveliaevelin
You can simply disable including version info in the project options, and you won't get a duplicate resource error, while being able to set other data that are set in the default .res file.Nejd
Please note that when you remove the {$ *.res}, you also loose the main application icon as set by the project options and will need to include one yourself using a .rc file.Recipe
That looks like what i'm looking for. Unfortunately i get an error message if i try to build the project. Here's what i've done: - create a txt file and save it as versioninfo.res - content of the res file: bit.ly/cH70KN - link it as resource file with {$R versioninfo.res} The error message is: [Error] RLINK32: Unsupported 16bit resource in file "...\versioninfo.res" Any idea what i'm doing wrong?Scow
@pantarhei: What you're doing wrong is trying to link a text file in as a RES file. That's failing for the exact same reason that trying to link source code into your EXE would fail: it's not compiled. Save your text file as a .RC file and copy the syntax Rob used exactly. {$R resources.res resources.rc} This causes Delphi's compiler to invoke the resource compiler on resources.rc and build a valid resources.res from it.Seamark
@Rob: ah yes, indeed you did, my ol' eyes must have missed it last time around...Recipe
@Mason Wheeler: Makes sense. Never cared about resource files until now. So please forgive me my ignorance. After i added it as Rob said and you rememberd me it tells me: [Error] File not found: 'resources.res'Scow
Maybe the file names need to be quoted in the $R directive? I don't remember. Newer versions of Delphi (I'm not sure how new) allow you to simply add the RC file to your project: In the Project Manager, use the "add file" command. The IDE will take care of the rest of the syntax for you.Acetal
A
4

Solution would be to edit a project resource file. Check this c++ example http://www.codeproject.com/KB/cpp/UpdateVersion.aspx

Appraise answered 7/7, 2010 at 12:35 Comment(0)
R
4

I would recommend using a build tool, like FinalBuilder (which I use a lot), which can do this for you according to an appropriate scheme. Then you know that the build options are all as you wish, your numbers are incremented appropriately, and you can do things like upload to FTP site and lots more. In my scripts, the build number is included all the way through from EXE to installer and all.

Rebate answered 7/7, 2010 at 13:18 Comment(0)
D
3

You have to write wizard for that. Check out IOTAProjectOptions in D7IOTA.HLP file, source code of ToolsAPI unit and this thread

Deirdra answered 7/7, 2010 at 16:34 Comment(3)
Why the downvote? This answer actually provides the most direct answer to the question as posed!!! OK, so it turns out that the poster of the question was after something else, but this answer doesn't deserve a downvote for that! If anything the question should be. (StackOverflow should perhaps provide two rankings for the question: 1 for the question itself and another for how well the question was put/how clear it was/how close to the actual question required to be answered etc etc)Fuchsia
Probably, my solution looks too complex :-) However, either IDE maintains project resources exclusively or user have to do it manually. This is an only way for seamless integration.Deirdra
@DaveNottage, and not in archive. Link rot is a bitch!Deirdra
C
0

You'll need to overwrite the application resources. Good starting point would be probably XN Resource Editor which comes with source code http://www.wilsonc.demon.co.uk/d10resourceeditor.htm

worth reading is also Inno Setup (which does set icon for executable output) - http://jrsoftware.org/isdl.php

Courbet answered 7/7, 2010 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.