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
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
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
At work, we use Borland Starteam for code management and bug/change tracking. Lately, I have been using Git for code management, in addition. I really like having the benefits of Git, while not forcing the other developers to change how they work. Git can track all my little code changes, and then I checkin to Starteam to share with the other developers
I keep a Git bash (part of mSysGit) shell open all day while I’m working. It took a little while to get used to looking at Unix-style diffs (comparison of the last version of a file and what is currently on the disk), but now I definitely prefer it to working in Starteam or with TortoiseSVN which force you to use the mouse. Also Starteam has the nasty habit of not being able to determine the Status of a file, constantly saying Unknown even after an explicit Refresh (F5) and right click -> Update Status, instead of realizing a file is Current or Modified.

(more…)
posted by Jason at 11:08 pm

As a follow up to my first post on JQuery in a TWebBrowser, I wanted to add the JQuery plugin TableSorter to an HTML report in order to add interactive sorting. Again, I wanted the program to be fully self-contained, so I didn’t want to add any <script> tags referring to temp files or anything like that.
Download the Delphi project which injects JQuery, JQuery plugin cssRule and JQuery plugin TableSorter. I tested that it works with Delphi 2006 and Delphi 2009.
(more…)
posted by Jason at 1:47 am

The GoogleMaps API has a GDirections object which can be used to retrieve directions between points. Full JavaScript applications are possible, but interaction with Delphi allows further possibilities. Previous demo programs showed how to call JavaScript from Delphi, this demo also allows the JavaScript to call Delphi functions (using JavaScript’s external object, explained later).
The demo program allows you to enter two or three addresses, and will retrieve the directions with the GoogleMaps API. The directions will be sent to Delphi from JavaScript, and they will be displayed in a TListBox. Clicking on an item in the TListBox will show the map “blowup” (a zoomed in box for a step, as seen in the screenshot above).
(more…)
posted by Jason at 12:04 am
I received an email about my first Google Maps in a TWebBrowser post asking how to remove the white border around the map, in order to let the GoogleMap fill the whole area of the TWebBrowser.
The white border is simply the default margin of the body of the document. Adding style=”margin:0″ to the <body> tag will push the map to the upper left (so changing the original example, the new line will be “<body onload=”load()” onunload=”GUnload()” style=”margin:0″>”).
Allowing the map to fill the whole TWebBrowser is a little more involved.
(more…)
posted by Jason at 1:09 pm
I wanted to find a way to use JQuery from Delphi on a page in a TWebBrowser, without requiring downloading over the internet, nor from the filesystem.
Download the Delphi 2009 project.

It turns out you can just execute the whole contents of the JQuery javascript file.
(more…)
posted by Jason at 9:42 pm
At work, we use ADO exclusively to connect to MS SQL Server, and I’m interested in exploring some of the things you can do with dbExpress and metadata, so I am trying to figure out how to create a connection on the fly, without setting up a new connection through Delphi, to be stored in the dbx ini files. I recently read a newsgroup post about deployment problems with Delphi 2009 needing dbxconnections.ini and dbxdrivers.ini, but I think eventually, it will be fixed.
(more…)
posted by Jason at 12:12 am
Here is a simple program to show how you can “host” google maps in a TWebBrowser and interact with it from a Delphi application.
Download the Delphi project

GoogleMapsTest Program Screenshot
I saw a recent newsgroup post at borland.public.delphi.language.delphi.general Google Maps geocoding service with TWebBrowser and I had seen some interesting posts by former CodeGear employee Steve Trefethen (Using Google Maps From a Windows Client Application). Having played a little with googlemaps hosted in a webpage, and also with a TWebBrowser in a Delphi application hooking into JavaScript events, I thought I would throw together a little test app to at least have one full working example for people to look at.
(more…)
posted by Jason at 10:12 pm