title: Delphi: At runtime find classes that descend from a given base class?
body: <p>Is there at way, at runtime, to find all classes that descend from a particular base class?</p>
  
  <p>For example, pretend there is a class:</p>
  
  <pre><code>TLocalization = class(TObject)
  ...
  public
     function GetLanguageName: string;
  end;
  </code></pre>
  
  <p>or pretend there is a class:</p>
  
  <pre><code>TTestCase = class(TObject)
  ...
  public
     procedure Run; virtual;
  end;
  </code></pre>
  
  <p>or pretend there is a class:</p>
  
  <pre><code>TPlugIn = class(TObject)
  ...
  public
     procedure Execute; virtual;
  end;
  </code></pre>
  
  <p>or pretend there is a class:</p>
  
  <pre><code>TTheClassImInterestedIn = class(TObject)
  ...
  public
     procedure Something;
  end;
  </code></pre>
  
  <p>At runtime i want to find all classes that descend from <code>TTestCase</code> so that i may do stuff with them.</p>
  
  <p>Can the RTTI be queried for such information?</p>
  
  <p><strong>Alternatively:</strong> Is there a way in Delphi to walk every class? i can then simply call:</p>
  
  <pre><code>RunClass: TClass;
  
  if (RunClass is TTestCase) then
  begin
     TTestCase(RunClass).Something;
  end;
  </code></pre>
  
  <h2>See also</h2>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1986335/finding-all-classes-that-derive-from-a-given-base-class-in-python">Finding all classes that derive from a given base class in python</a></li>
  <li><a href="https://stackoverflow.com/questions/205573/java-at-runtime-find-all-classes-in-app-that-extend-a-base-class">Java: At runtime, find all classes in app that extend a base class</a></li>
  </ul>