title: Automating RegisterClass in C++ Builder VCL
body: <p>We use C++ Builder for an application whose forms are kept external to the EXE in a database.  Application code is C++</p>
  
  <p>This allows us to modify the forms and form/actions without a re-compile.  Here is a snippet of code that gets the job done of loading a form.</p>
  
  <pre><code> RegisterClass(__classid(TButton));
   RegisterClass(__classid(TEdit));
   RegisterClass(__classid(TRadioGroup));
   RegisterClass(__classid(TGroupBox));
   RegisterClass(__classid(TCheckBox));
   RegisterClass(__classid(TRadioButton));
   RegisterClass(__classid(TTimer));
   RegisterClass(__classid(TListBox));
   RegisterClass(__classid(TComboBox));
   RegisterClass(__classid(TBitBtn));
   RegisterClass(__classid(TSpeedButton));
   RegisterClass(__classid(TMaskEdit));
   RegisterClass(__classid(TProgressBar));
  
   ms  = new TMemoryStream;
   ms2 = new TMemoryStream;
  
   // Loading Module into Memory Stream
   ms-&gt;Position = 0;
   ms-&gt;LoadFromFile(Filename-&gt;Text);
   ms-&gt;Position = 0;
   pModule = new TForm(this);
  
   // Reading Module Definition
   if( !Inputisbin-&gt;Checked )
   {
          ms2-&gt;Position = 0;
          ObjectTextToBinary(ms, ms2);
          ms2-&gt;Position = 0;
          ms2-&gt;ReadComponent(pModule);
   }
   else
          ms-&gt;ReadComponent(pModule);
  
  
   Log-&gt;Lines-&gt;Add("Displaying Module");
   pModule-&gt;Show();
  </code></pre>
  
  <p>I'm curious to know if there are any built-in functions I can call to register all classes referenced.  I suppose it's possible to scan the memory stream or file for all objects myself and call RegisterClass for each but was hoping someone knew of function that already did this.</p>
  
  <p>As such, not all forms use all these classes either so it would be nice to only register those that are actually inherited.</p>