L
liuguilg
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了个bpl,用一个不带窗体的类实现接口函数,主程序该如何调用它?:接口pas:unit Unit_DeFine_interface;interfacetype IMy_interface=interface(IUnknown) ['{9C30C81B-0CCB-4459-B8FF-5306C0309473}'] function fn_add(x1,x2:integer):integer; end ;implementationend.接口的实现单元--------------------------unit UnitInterface;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,Unit_DeFine_interface;type TImpInterface=class(TInterfacedPersistent, IMy_interface) private { Private declarations } public { Public declarations } function fn_add(x1,x2:integer):integer; end; implementation{ TImpInterface }function TImpInterface.fn_add(x1, x2: integer): integer;begin result := x1 + x2;end;initialization RegisterClass(TImpInterface);finalization UnRegisterClass(TImpInterface);end.接下来主程序该如何调用它,我这个是没有窗体bpl;我用这个方式来获取bpl里面的类,结果获取不到var BPLClass:TClass;begin BPLClass:=GetClass('TImpInterface'); //结果BPLClass=nil请问该怎么实现?