H
hsgrass
Unregistered / Unconfirmed
GUEST, unregistred user!
// 这是在BPL里面的单元内容,为什么不能从窗体类TfPk1Mainfrm.queryinterface(IpkInfo, obj)
// 如果一个简单的工程, 即可以正确的查询出interface.
// Ipkinfo = interface
//['{73C1F90C-F6B9-404F-BD95-DEF008D06DCE}']
// function GetPluginID: string;
// end;
type
TfPk1Mainfrm = class(TForm, iPkinfo)
btn1: TButton;
lbl1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
function GetPluginID: string;
end;
Ttest = class(TinterfacedObject, Ipkinfo)
function GetPluginID: string;
end;
var
fPk1Mainfrm: TfPk1Mainfrm;
function gcn(out obj): boolean; stdcall;
procedure addctrl(out obj);
exports
gcn, addctrl;
implementation
{$R *.dfm}
procedure addctrl(out obj);
var
i: HRESULT;
t: Ttest;
begin
Application.CreateForm(TForm, fPk1Mainfrm);
i := fPk1Mainfrm.QueryInterface(ipkinfo, obj);
showmessage('TForm: ' + inttostr(i) + #13 + SysErrorMessage(i)); // 显示为不支持接口
fPk1Mainfrm.Free;
t := Ttest.Create;
i := t.QueryInterface(ipkinfo, obj);
showmessage('Tobject: ' + inttostr(i) + #13 + SysErrorMessage(i));
// t.free; // outside free
end;
// 如果一个简单的工程, 即可以正确的查询出interface.
// Ipkinfo = interface
//['{73C1F90C-F6B9-404F-BD95-DEF008D06DCE}']
// function GetPluginID: string;
// end;
type
TfPk1Mainfrm = class(TForm, iPkinfo)
btn1: TButton;
lbl1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
function GetPluginID: string;
end;
Ttest = class(TinterfacedObject, Ipkinfo)
function GetPluginID: string;
end;
var
fPk1Mainfrm: TfPk1Mainfrm;
function gcn(out obj): boolean; stdcall;
procedure addctrl(out obj);
exports
gcn, addctrl;
implementation
{$R *.dfm}
procedure addctrl(out obj);
var
i: HRESULT;
t: Ttest;
begin
Application.CreateForm(TForm, fPk1Mainfrm);
i := fPk1Mainfrm.QueryInterface(ipkinfo, obj);
showmessage('TForm: ' + inttostr(i) + #13 + SysErrorMessage(i)); // 显示为不支持接口
fPk1Mainfrm.Free;
t := Ttest.Create;
i := t.QueryInterface(ipkinfo, obj);
showmessage('Tobject: ' + inttostr(i) + #13 + SysErrorMessage(i));
// t.free; // outside free
end;