unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus,U_Myinterface;//在工程加入U_Myinterface这个unit,让exe也和bpl使用同一个接口。type
Tmain = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
bpl1: TMenuItem;
procedure bpl1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
my:Myinterface;
end;var
main: Tmain;implementation{$R *.dfm}procedure Tmain.bpl1Click(Sender: TObject);
var
hModule: THandle;
frm:TForm;
begin
hModule := LoadPackage('Plabel.bpl'); //动态载入包
frm:=TForm(TComponentClass(FindClass('Tform1')).Create(Application)); //创建form,
frm.ShowModal; //show出来,如果需要用MDI方式,只需要把form的formstyle改了,然后用下面的代码即可
my:=TComponentClass(FindClass('Tform1')).Create(Application) as Myinterface; //转化为接口
my.show123('11'); //调用接口函数
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus,U_Myinterface;//在工程加入U_Myinterface这个unit,让exe也和bpl使用同一个接口。type
Tmain = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
bpl1: TMenuItem;
procedure bpl1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
my:Myinterface;
end;var
main: Tmain;implementation{$R *.dfm}procedure Tmain.bpl1Click(Sender: TObject);
var
hModule: THandle;
frm:TForm;
begin
hModule := LoadPackage('Plabel.bpl'); //动态载入包
frm:=TForm(TComponentClass(FindClass('Tform1')).Create(Application)); //创建form,
frm.ShowModal; //show出来,如果需要用MDI方式,只需要把form的formstyle改了,然后用下面的代码即可
my:=TComponentClass(FindClass('Tform1')).Create(Application) as Myinterface; //转化为接口
my.show123('11'); //调用接口函数
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货