library ject1;
uses
windows,
SysUtils,
Classes,
k2 in k2.pas;
{$R *.res}
procedure biaoti;export;stdcall;
begin
form2.show;
end;
exports
biaoti;
begin
end.
**********************
程序中有两个窗体,程序一运行,既同时装入内存。在主窗体
在DLL中,form2需要重新初始化,不能直接使用主程序中已经初始化成功的实例,DLL没有办法拿到主程序中的对象指针
如果需要调用主程序的对象指针,试试看如下过程定义:
procedure biaoti(AForm: TForm);stdcall;
begin
AForm.Show;
end;
在DLL中必须Create
procedure biaoti;export;stdcall;
var
form2:TForm2;
begin
form2:=TForm2.create(nil);
form2.domodal;//最好这样,因为接下来还要释放内存
form2.free;
end;