Dynamic class creation

NOTE: The download link in the original version of this post got mangled by WordPress. It’s been corrected now.

A couple weeks ago, I gave a presentation at the CodeRage 4 online conference about dynamic class creation at runtime in Delphi.  The replays were just posted yesterday at Embarcadero’s CodeRage site My session can be downloaded here or viewed online here.  The sound quality was terrible, unfortunately.  I’m not sure what was going on with my headset the evening I recorded this, but it sounds like I was recording inside a giant water pipe, instead of sitting in my quiet, ordinary apartment room.  (And this was after editing.  It sounded even worse at first!)  Despite this, it was received fairly well, with a bunch of good questions and comments.

I showed a demo of a tool I’d written to explore the structure of a class, plus a code library for creating new classes at runtime.  I just put it up for download if anyone wants to play around with it.  You can find it here.  The dproj file is in Delphi 2010 format, and I haven’t tested it with any earlier versions, but I’ve tried to use IFDEFs to define out code that wouldn’t run on earlier versions, and this ought to work on any version from D5 on.  Take a look, and feel free to use it in your own projects if you can find some use for it.  And of course, if there’s any way you find to improve on it, please let me know.
Mason Wheeler

3 Comments

  1. […] set this up to load itself into my class RTTI inspector tool, and used Delphi 2010’s trick of casting an interface to an object, and it worked! And […]

  2. Wanc says:

    Well, nice post. How about to show a code to explain how to use a dynamic class? Maybe including how to create object from that class and using it in real world…
    Thanks.

  3. Luis Ramos says:

    very well; thanks a lot!