Ramblings

Delphi Programming Observations

Source Code License About Contact

Friday, May 8, 2009

Program To Set Delphi Resource Version Info from commandline

With Delphi’s decision to move to using MSBuild, building Delphi projects from the commandline became a lot easier, but it lacks a way to set the Version Info on the resultant EXE.

Using the code from the XN Resource Editor, it was pretty easy to write a commandline program to change the Version Info stored in a Delphi Resource file, SetVersion.exe. The source code for XN Resource Editor is available at http://www.wilsonc.demon.co.uk/delphi.htm. I found one little problem with the Delphi 2009 version, the RES files were being corrupted after running the SetVersion.exe program, but simply changing a Char and PChar to Byte and PByte fixed it.

Calling the program before calling MSBuild (or DCC32 if you don’t use the latest Delphi) will allow you to set the Version Info, which will be compiled into the EXE.

See the github repository for the source code (SetVersion/ directory). The code only compiles with Delphi2009 (I tried with Delphi 2006 and it failed), but I think it should only take getting the correct version of the XN Resource Editor’s source code files at http://www.wilsonc.demon.co.uk/delphi.htm and dropping them into Others/ColinWilson/.

posted by Jason at 11:49 pm  

Friday, May 1, 2009

Using DLLs stored as Resources in Delphi programs

There are a few DLLs which my Delphi programs interface to, which were developed in other languages. Using LoadLibrary() and GetProcAddress(), your code can avoid crashing by checking for the existance of the DLL. This also allows storing the DLL as a resource, inside the executable, which you can extract to the filesystem and before calling LoadLibrary() and GetProcAddress().

Extracting the DLL to the filesystem works, but there is a better way: BTMemoryModule. BTMemoryModule allows you to extract the DLL to a TMemoryStream, and use it as a DLL, with BTMemoryLoadLibrary and BTMemoryGetProcAddress.
(more…)

posted by Jason at 7:31 pm  

Powered by WordPress