i did some tests about modular applications mechanism .
the base thing i tried is load packages at run time and playing with classes inside it .
my test was around building form in my package and load form "TCustOrder" from my host application the test succeeded very well .
the problem is :
My TCustOrder has property named "Client:TObject" how can i access this property from the host application .
The Code :
var x : HRESULT ;
AClass : TPersistentClass ;
FormOrder : TForm ;
begin
x := LoadPackage('Cutorder.bpl') ;
if x <> 0 then
begin
AClass := GetClass('TCustOrder');
if AClass <> nil then
FormOrder := TComponentClass(AClass).Create(Application) as TForm;
if Assigned(FormOrder) then
begin
FormOrder.Show
end;
end;
The application should know the base of a class to use it. The interface, protocol, specification, you name it. The particular package gives a certain specialized implementatino of it.
So the overall structure, based on BPL and conventional objects, should be the one that you can observe in VCL itself.
Base.BPL - contains
TBaseClass
andTList<TBaseClass>
of implementations provided by plugins. It also contains all virtual methods and properties needed for main program to use it. It is convenient to haveApp.Exe would list Base.BPL among its runtime packages (in project options) and use Base.BPL as a "meeting point" with plugins.
Plugin.BPL would list Base.Bpl as required runtime package and use it as rendezvous place too.
Note, at least Delphi XE2 tends to destroy string array constants when unloading dynamic packages. Dunno if it holds for D2010. In XE4 it was fixed. So "dragons may be here". In modern Delphi there are a lto of bugs in RTL/VCL, be ready to debug them.