About the author
In Delphi 8 Control Panel Applet Mystery, I wrote about how I tried porting the Control Panel applet from Delphi 7 and some problems associated with it.
After working for a few hours on this, I've finally solved the issue.
The unit initialization code in a Delphi unit is called by the class constructor for that unit. The class constructor for a unit is called once, when any variables, classes, or procedures in that unit is referenced once, either statically or dynamically. Subsequent references to any variables, classes, or procedures in that unit do not invoke the class constructor, which therefore, do not invoke the unit initialization code.
In the article, I used reflection to call the main initialization code. That is an error. What should have been done instead is to create an empty procedure with a known name, and call that empty procedure by reflection. Before the empty procedure is called, the class constructor would be called. The class constructor, in turn, would call the unit initialization code.
I have now created a fully functional Control Panel applet in Delphi 8.
To look at the .NET binary, which presents the same functionality as the Delphi 7 Date demo, download from here. NB: You need to have Delphi 8 with Update Pack 2 installed, since I have compiled this demo with packages.