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
Comments (14)
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?
Thanks
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 ?
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.
Yes, that resourceutils.zip in /d6/ is not the version for Delphi 2009, Colin Wilson has separate zip files for different Delphi versions; the files I used are actually in http://www.btinternet.com/~wilsoncpw/d12runtimepackages.zip. The site is confusing to navigate and some of the links change which delphi version they are referring to.
The files in my github repository actually fix one problem I noticed with PChar/PByte, as noted in the first SetVersion.exe post
Thank you for your job. Well done.
Delphi is for losers, FU.
and that must make you a winner, right?
Hi,
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.
Thanks,
Sam
I don’t use D7, so I’m not sure. I think I tested it with D2006-D2009, built with D2009. The only time I got damaged RES files was before I found the problem in unitResFile.pas, http://github.com/jasonpenny/democode/commit/e86bc260ab50a31c01a50593a79711047dff2aba . Also, if the RES file does not already have version information, that could also be a problem.
As I said, I don’t use D7, but there shouldn’t be too many changes needed to make it compile with D7 to see if that helps (Colin Wilson’s site has a D7 version of ResourceUtils, http://www.wilsonc.demon.co.uk/delphi_7.htm )
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.
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.
Hi – does this work with BPL files? From what I can see its just EXE and RES – Cheers
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.
[...] 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 [...]