开发者

Can Dlls provide modularity to main program?

Simple task: I would like to make a progra开发者_JAVA百科m (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?

Thanx

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';

var
  ParentForm: TParentForm;

implementation

{$R *.DFM}



procedure TParentForm.Button1Click(Sender: TObject);
begin
  ShowForm1;
end;

procedure TParentForm.Button2Click(Sender: TObject);
begin
  ShowForm2;
end;

procedure TParentForm.Button3Click(Sender: TObject);
begin
  ShowForm3;
end;


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜