同意肥羊的,你应该还传入一个screen,否则是无法访问MDIChildCount的:
不过你别忘了,在传入application和screen以前先把dll本身的application和screen保存起来,否则在dll线程结束释放资源的时候可能会出错
主进程:
type
TShowFrm = procedure(App: TApplication; Scr:TScreen); stdcall;
...
implementation
...
procedure TForm1.Button2Click(Sender: TObject);
var
AFunc: Pointer;
begin
Pointer(AFunc) := GetProcAddress(hInstance, PChar (‘ShowFrm‘));
TShowFrm(AFunc)(Application, Screen);
end;
//---------------------------------------------------
DLL工程文件:
procedure ShowFrm(App:TApplication; Scr: TScreen); stdcall;
begin
Application := App;
Screen := Scr;
App.CreateForm(TForm2, Form2);
Form2.Show;
end;