您的位置:首页 > 编程语言 > Delphi

Delphi 在使用exports中的方法 带参数的用法

2013-09-27 15:50 267 查看
最近项目中,需要在一个bpl中调用另一个bpl中的单元的方法, 方法如下:

在被调用的单元中定义:

procedure Inner_Ex(VoucherType: TVoucherType);

exports Inner_Ex;

实现:

procedure Inner_Ex(VoucherType: TVoucherType);
var
frm: tfrmaaa;
begin
frm := tfrmaaa.Create(Application);
try
frm.VoucherType := VoucherType;
frm.ShowModal;
finally
frm.Free;
end;
end;

在那个bpl中调用

首先:定义一个过程变量

TMyProcedure1 = procedure(x: TVoucherType); //20130927 zzf 添加

实现:

procedure Inner_Stuff;
var
Handle: THandle;
MyProcedure: TMyProcedure1;
Begin
//声明
MyProcedure := nil;

if Handle = 0 then
Handle := LoadPackage('Ple.bpl');
if Handle <> 0 then
@MyProcedure := GetProcAddress(Handle, 'Inner_Ex');
if Assigned(MyProcedure) then

///调用
MyProcedure(sNC);
end;

上面的例子就是把带参数,调用bpl方法的例子。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: