Take the 2-minute tour ×

Simple task: I would like to make a program (parent.exe). There are three buttons. When I click Button1, Form1 appears; when Button 2, Form2 appears; when Button3, Form3 appears...

Form1, Form2, Form3 are stored in three different dlls (Form1dll.dll, Form2dll.dll, Form3dll.dll).

I wanted to make parent program (parent.exe) run modular. I planned to add and remove dlls, but Parent.exe requires all dlls to be present, otherwise an exception occures.

How can I solve the problem?


Here is code from parent.exe:

  procedure ShowForm1;stdcall;external 'Project1dll.dll' name 'ShowForm1';
  procedure ShowForm2;stdcall;external 'Project2.dll' name 'ShowForm2';
  procedure ShowForm3;stdcall;external 'Project3.dll' name 'ShowForm3';

  ParentForm: TParentForm;


{$R *.DFM}

procedure TParentForm.Button1Click(Sender: TObject);

procedure TParentForm.Button2Click(Sender: TObject);

procedure TParentForm.Button3Click(Sender: TObject);
share|improve this question

2 Answers 2

up vote 5 down vote accepted

The way you've got it set up, the program looks for the DLLs at load time. What you need is to set the DLLs up as plugins. Take a look at the JVPlugin framework in the JVCL. It has exactly what you're looking for.

share|improve this answer
You should enable Runtime Packages before attempting to use Plugins (JVPlugin or any other). You must load the core RTL/VCL classes from a package, instead of statically linking them, so that one common copy of all core shared Class code and data structures are shared among your main application and its plugins. –  Warren P Dec 30 '09 at 15:06
Yes, but only if you use BPLs for the plugins. It's possible to use DLLs too. –  Mason Wheeler Dec 30 '09 at 16:22

Yes it can by having the EXE Dynamically load the DLLs using LoadLibrary and GetProcAddress. See http://www.scalabium.com/faq/dct0130.htm for an example.

Next you might run into other problems because the memory manager and types are not shared between the EXE and the different DLLs. You might need to take extra care to circumvent these problems or look for solutions. Like runtime packages/BPLs or special memory managers.

share|improve this answer

Your Answer


