Delphi: Can you have a component class definition in a DLL and load and create it at runtime?

components, delphi, dll

Solution

That's what packages are for. They are a kind of DLL that is improved to play well with Delphi classes (including components).

Just remember that you'll need to distribute RTL[ver].bpl, VCL[ver].bpl and any other necessary Runtime Packages alongside your executable and DLL.

Ideally you should test your application on a VM or system which has never had Delphi/RAD Studio installed on it. This way, if your distribution is missing any required Package files, the Execption dialog will tell you what files you need to include.

Problem

Sorry if this is a silly question but it's not something I've had to do before. Is it possible to create a component class, say, a descendent of TPanel or TDBGrid, in a DLL, and then load that DLL at runtime in another application, which then creates those controls and uses them like normal Delphi components? If so can you give me any pointers as to where to look to start doing this?

Original source