Delphi Programming Observations

Saturday, September 5, 2009

Updated SetVersion.exe to set File Version info in RES or EXE

My first version of the SetVersion.exe tool to update the Version Information of a Delphi executable allowed you to set the version info stored in a Delphi Resource file (*.RES), which is the main place Delphi stores it.  When you perform a build in Delphi, the version info in the Resource File will override anything defined in a *.BDSPROJ or *.DPROJ for the resulting binary (*.EXE, *.DLL).

Now, SetVersion.exe will allow you to set the Version Information on an EXE file after it has been built. See latest code at github.com/jasonpenny/democode

posted by Jason at 12:17 am  

14 Responses to “Updated SetVersion.exe to set File Version info in RES or EXE”

  1. Greg says:

    Hello Jason,

    I have used your SetVersion code and had to slightly alter it for Delphi 6 as a record couldn’t contain function / procedures in it and it worked.

    But I want it to work under my new Delphi 2009 and now this whole mess with changes dealing with ansistring, pchar, pwidechar and so forth seem to be causing an issue when compiling.

    Specifically the following to procedures don’t compile:

    ResourceWideCharToStr, ResourceStrToWideChar

    I got rid of the errors by replacing the PChar with PAnsiChar, but when I run it I am getting the “Exception: No VersionInfo found in…” and I know there is. The only thing I can think of is my correction switching PChar to PAnsiChar isn’t the solution even though it compiles.

    Do you happen to have Delphi 2009 and see if you can get it to work?


    • Jason says:

      Are you trying to compile the code that you altered for Delphi6?

      I used Delphi2009 to create the program to begin with, and I get no errors or warnings when I compile with the versions of files on github. Did you make changes or overwrite Others\ColinWilson\unitResourceDetails.pas ?

  2. Greg says:

    No… the Delphi 6 one was done on a different unit and working fine.

    The Delphi 2009 is using your exact code from the following link: http://www.wilsonc.demon.co.uk/files/d6/resourceutils/resourceutils.zip

    Which I believe is the issue. I originally found your code from the link above, but I have now found the github site and see the code is different… it doesn’t even have those procedures I mentioned above.

    Either way I am good to go. By the way the original site I found was http://www.wilsonc.demon.co.uk/delphi_6.htm which may not have the latest code.

    Good job on your code. I was trying to create my own build server using the command line compiler and the version crap was killing me since I couldn’t get it to update.

    Again… good job and thanks.

  3. Jbrek says:

    Thank you for your job. Well done.

  4. dash says:

    Delphi is for losers, FU.

    • Jason says:

      and that must make you a winner, right?

  5. Sam says:


    for which versions of delphi can your application SetVersion.exe be used ?

    I downloaded the sources and compiled SetVersion.exe with D2010.
    Then I ran SetVersion.exe with -i -s options against a Package which I use currently with D7.
    After that, the .res file was damaged and not readable by D7 anymore.



  6. Sam says:

    Thank’s. Now it works fine! Had to do the changes in unitResFile.pas as you suggested. And it also works with D7.

    Now another question…
    I am the Dev. of the DelphiPackageTool. It’s an opensource/freeware tool to install/compile larger groups of dpr,dproj,dpk-file.

    For more Info look here: http://cc.embarcadero.com/Item/22778
    For the sources look here: http://sourceforge.net/projects/delphipackageto/

    May I put your SetVersion.exe into my setup.exe ? If so, which licence files shall I add or shall I mention your name in my about-box ?

    Thank you.

    • Jason says:

      Sure, you may include it. You don’t have to do anything special as far as I’m concerned, though it might be nice to put a link to Colin Wilson’s site, http://www.wilsonc.demon.co.uk/delphi.htm , since most of the heavy lifting is done by his ResourceUtils code.

  7. Richard Warriner says:

    Hi – does this work with BPL files? From what I can see its just EXE and RES – Cheers

    • Jason says:

      The code specifically looks for .EXE and .RES extensions, so as the code is now, it won’t work, but you can add checks for .BPL or .DLL and the rest of the code will work to update the Version Resource.

  8. [...] ist aber gar nicht notwendig. Ein fertiges Open Source Tool, das das damit macht, findest du hier: /blog/2009…in-res-or-exe/ Wir machen das aber anders: Ich schreibe die Version einfach im PreBuild-Event mit diesen Units in [...]