Using my buildtools

 Delphi, dzLib  Comments Off on Using my buildtools
Sep 262015

My buildtools for Delphi have been available on SourceForge for quite a while. I use them in all my projects, including – slightly modified – in GExperts. Just in case somebody else is interested, I’ll outline how to use them in a project.


First, your project has to follow the following structure:


Notice that the main project directory should have the same name as your project, so if the project is called MyProject, the directory should have the same name (Exceptions are possible, see below). Also, the project files should be in a subdirectory called src (this cannot easily be changed).


If these requirements are met, you can just add the build tools as an svn:external to a subversion project like this:


This will create a subdirectory buildtools to the project’s main directory.

If your main project directory name is different from your project name, create a __SetProjectName.cmd script that sets the environment variable PROJECT to your project name:

set PROJECT=MyProject

All scripts will try to call this in order to get the project name. If it does not exist, the project name will be assumed to be the same as the main project directory.

The first step should now be to execute the script __CopyTemplates.cmd located in buildtools\templates. It will do the following:

  • Copy _BuildProject.cmd, _OpenInIde.cmd and _AutoBuildCheck.cmd to the project directory
  • Copy to src\
  • Copy template_icon.rc to src\%project%_icon.rc if it does not exist
  • Copy template_version.ini to src\%project%_version.ini if it does not exist.
  • open src\%project%_version.ini in notepad to be adjusted for the given project

src\%project%_version.ini is an ini file that maintains the version info of the project. The Delphi IDE (since Delphi 2005 and up until recently) notoriously mishandled the version information, so at some point I grew tired of it and moved the handling of version information to an external tool. More on that later. The format of the INI file should be familiar to all who have used Delphi 7 or earlier. The Version info in the .dof file there was in the same format.

The build tools assume that the project uses Delphi 2007 since that is the version with which I (have to) do most of my development work. If your project uses a different version, create a __DelphiVersion.cmd file with the following content:

set DelphiVer=XE2 

Replace the XE2 with your Delphi version:
6, 7, 2005, 2006, 2007, 2009, 2010, XE, XE2 … XE8 (I have yet to add Delphi 10 Seattle)

Now you should be able to open the project in the Delphi IDE by executing the _OpenInIDE.cmd script, do a commandline build by executing the _BuildProject.cmd script.

That’s the general preparation, now for the actual advantages of using these tools:

Version Information, Icon and Manifest
Up to Delphi 7 you could enter the version information into the projects settings dialog, check the “auto inc build number” option and let the IDE do everything else. The information was stored in the project.dof file. There was the disadvantage that the project.res file changed with every build but most people didn’t mind that much. If you deleted the .res file, it would be recreated with the correct version info, all you lost was the icon. Unfortunately a command line build using dcc32 did not increment the build number. Then Borland jumped on the dotNET wagon and created a new IDE. This new IDE botched the handling of the version info vs. the project.res file completely. Now, the master version information was stored in the project.res file and the IDE updated the project.bdsproj file (and later the project.dproj file) from there. The command line compiler still did not increment the build number.

At that point I got fed up and wrote dzPrepBuild. It is a small tool that can read and modify .dof, .bdsproj, .dproj and .ini files. But the most important function is creating a .rc file with the version information that can be compiled to a .res file which in turn can be used by Delphi to add version information to the executable. It also creates a manifest file for Windows Vista and later, containing the version information.

So, in order to use it, do the following:

  • Disable version information in your project
  • Add the following Pre-Build event (Delphi 2007 and up):
    call ..\buildtools\prebuild.cmd $(PROJECTPATH)
  • Add the following Post-Build event (Delphi 2007 and up):
    call ..\buildtools\postbuild.cmd $(OUTPUTDIR)$(OUTPUTNAME)
  • In the project.dpr file remove the {$ *.res} line
  • and add the following lines
      {$R *_version.res}
      {$R *_icon.res}
      {$R *_manifest.res}

If you use a Delphi version older than Delphi 2007, you must find another way to call the prebuild and postbuild scripts, because Pre- and Post-Build events were only introduce with Delphi 2007.

So, what does prebuild.cmd do?

  • It increments the build number in src\%project%_version.ini
  • Writes a src\%project%_version.rc from this information
  • If src\ exists, writes a src\%project%.manifest and a corresponding src\%project%_manifest.rc
  • Calls brcc32 to compile src\%project%_version.rc to a .res file
  • If src\%project%_manifest.rc exists, calls brcc32 to compile it to a .res file
  • If src\%project%_icon.rc exists, calls brcc32 to compile it to a .res file

Oh, I haven’t mentioned the %project%_icon.rc file yet: It’s a text file that only contains one line:


You should adapt it to point to the .ico file you want to use for your project. Alternatively you can delete the .rc file if you don’t want to have an icon. In this case you also must remove the {$R *_icon.res} line from the project.dpr file. Here is a hint on creating icons from multiple png files.

Regarding the manifest: Newer versions of Windows (starting with Vista) have the (I think) annoying habit of virtualizing access to the registry and some file system folders to which a program does not have write access. If you don’t tell Windows to not do that, you will not even notice your programming errors. To tell Windows to go and play somewhere else, you need a manifest. A manifest is an xml file that is added to the executable as a resource. That’s what the project_manifest.rc file does. Windows looks into that xml file in order to find out whether the program is compatible to a particular Windows version. The file in buildtools\templates contains the following text:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  This manifest tells Windows Vista (and Windows 7/8) not to virtualize any file
  or registry access. Also, it disables themes support.
  <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version=""
    name="template from dzlib build tools"
<!-- We do not want themes support
    <assemblyidentity type="win32"
      language="*" processorarchitecture="*">
  <description>This application was built using buildtools from dzlib</description>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
      <!-- We support Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!-- We support Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!-- We support Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <!-- We support Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <!-- We support Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">

Apart from claiming compatibility to Windows Vista, 7, 8, 8.1 and 10 this manifest also disables theming (you might want to change that) and tells Windows to not run with any elevated privileges. MSDN has some more information on manifests.

Please note that the manifest also contains the version information. The prepbuild tool will read src\ and create src\%project%.manifest, overwriting the latter if it exists. So in order to change the manifest, you should edit src\

JclDebug Information and Translation

The postbuild.cmd file’s job is to do the following:

  • Append JclDebug information to the executable by calling the AppendJclDebug.cmd script, which in turn calls the makejcldbg executable
  • Append translations for dxGetText to the executable by calling AppendTranslations.cmd which in turn calls the dxgettext tools.

I have written a separate blog post on Using JclDebug in your program. See there for an introduction on how it works. For the above to work, you should enable a full map file in the project’s Linker options.

AppendTranslation.cmd assumes that you use GNU Gettext for Delphi and C++ Builder (dxgettext) for translating your projects. It expects translations for German, English and French in subdirectories of translations:


The translation files themselves are called default.po and can be created with either the explorer extensions that come with dxgettext or by copying the _ExtractTranslations.cmd script from builtools to the main project directory and executing it there.

The .po files are compiled to binary .mo files which are created in the corresponding directory under locale:


You must create these directories for the AppendTranslation.cmd script to work. (Edit: A new script in buildtools PrepareForTranslation.cmd can do that for you. — 2015-10-4 twm)

That’s it for now. I hope this short overview isn’t too confusing for somebody who hasn’t used the buildtools before. If you like them, feel free to use them. If you have suggestions, please contact me through my Google+ profile.

 Posted by on 2015-09-26 at 14:15

Delphi7Help4BDS updated for Delphi XE7 to 10 Seattle

 Delphi  Comments Off on Delphi7Help4BDS updated for Delphi XE7 to 10 Seattle
Sep 252015

I have just updated my Delphi Help Expert to support Delphi XE7, XE8 and 10 Seattle.

It allows to reconfigure F1 + any of the modifier keys Shift, Ctrl, Alt and Alt+Ctrl to call either a help file (you will need the old winhelp viewer that Microsoft dropped with Vista(?)), chm file or internet url. It comes preconfigured with a few example internet urls for searching with Google, Bing, the Embarcadero docwiki or MSDN.

This shows the result of Alt+F1 when the cursor was on the keyword “Integer”:

Delphi Help Expert

To install it, get the sources from OSDN, open the package for your Delphi version, compile and install it. You should then find a new entry in the IDE’s Help menu called “Configure Delphi7HelpForBds” which gets you a dialog where you can configure the actions for each of the key combinations.

Delphi Help Expert

 Posted by on 2015-09-25 at 20:59

Delphi IDE Explorer Expert for Delphi 2007 – 10 Seattle

 Delphi, DelphiIdeExplorer  Comments Off on Delphi IDE Explorer Expert for Delphi 2007 – 10 Seattle
Sep 252015

I wrote this Delphi IDE Explorer Expert when I was trying find the button for showing and hiding the background for the Firemonkey mobile form designer and turn the bloody thing off for good.

Now I have ported it to all Delphi versions from 2007 to 10 Seattle. You can find the sources on SourceForge.

 Posted by on 2015-09-25 at 19:55

Remove the ad banner on the Delphi 10 Seattle welcome page

 Delphi  Comments Off on Remove the ad banner on the Delphi 10 Seattle welcome page
Sep 062015

I don’t know what Embarcadero thinks they can accomplish by showing their customers an annoying ad banner for the product they have already bought, but I don’t like that and this post helped me to get rid of it.

There are two steps:

  1. Locate the file that is being displayed. There are multipe default.htm files in your Delphi 10 Seattle installation. The one being displayed is the one in the subfolder under Welcomepage that corresponds to your language. In my case it was
  2. Open this file in a text editor and let it search for “topbanner”. There is a <div> with this name. You can either simply delete it, or place html comments
    <!-- ... --> 

    around it. (I did the latter.)

If you are feeling adventurous, you could also make additional changes, e.g. add a link to the Delphi category of my blog:

<a href=""></a>

Or if you want to see the built-in browser crash, you could add a link to my Delphi rss feed instead:

<a href=""></a>
 Posted by on 2015-09-06 at 12:47

Experimental GExperts Version 1.37 2015-09-06 released

 Delphi, GExperts  Comments Off on Experimental GExperts Version 1.37 2015-09-06 released
Sep 062015

The latest version is the first version that supports Delphi 10 Seattle.

There is nothing really new about the formatter code. Achim Kalwa submitted a patch that solves yet another Unicode issue, this time with the Code Proofreader expert.

Another change is that there won’t be a regular expert dll this time. After polling on Google+ and getting no definite result, I decided to only keep the version that I personally am using. This applies only to the Delphi 10 Seattle version for now, but I might also remove the regular expert dll from future releases.

Again, since we don’t have an official GExperts release for Delphi 10 Seattle yet, you will have to install it by hand. Here is the relevant extract from the readme file:

** Installing without an official installer **
With two Delphi Releases per year and Erik Berry being busy otherwise,
new GExperts releases have been lagging behind. So in case there is no
official GExperts installer yet, these are the steps to install the
experimental version by hand:

1. Create a suitable GExperts directory. It doesn't have to be a
   subdirectory of %ProgramFiles% but may be anywhere, even on a network
   share if you are sure this share will always be available.
2. Extract all files from the ZIP somewhere
3. Copy all files from the extracted directory to the GExperts directory.
   (Do *NOT* copy the subdirectories!)
4. Copy the appropriate GExperts DLL from one of the subdirectories
   EditorExpert or RegularExpert to the GExperts directory.
5. Copy the files from the subdirectory FromRegularRelease to the
   GExperts directory.
6. Copy the appropriate cmd from the install subdirectory. To the GExperts
7. Make sure that the Delphi IDE is not running
8. Run the cmd file. It will register the GExperts dll with the Delphi IDE.
9. Start Delphi and check that the new GExperts DLL has been loaded by
   opening the GExperts About dialog.

In theory it is possible to install GExperts for all Delphi versions into
the same GExperts directory. But be warned: This has not been tested

Head over to the Experimental GExperts page to download the new version.

 Posted by on 2015-09-06 at 11:43

Rebooting a Linux server unattended

 Linux  Comments Off on Rebooting a Linux server unattended
Sep 042015

Just so I can look it up when I need it again:

/sbin/shutdown -r now

is the command that when run as root will reboot a Linux server.

It can simply be added as a scheduled command in WebMin:

 Posted by on 2015-09-04 at 09:52