【发布时间】:2012-03-22 06:51:55
【问题描述】:
将com dll文件导入delphi后,delphi又生成了一个lib_tlb.pas文件。
检查它显示的文件
Iinterface1 = interface(IDispatch)
function func: Integer; safecall;
procedure proc(param:Iinterface1);
end;
Cointerface1 = class
class function Create: Iinterface;
class function CreateRemote(const MachineName: string): Iinterface1;
end;
Tinterface1 = class(TOleServer)
function func: Integer;
procedure proc(param:Iinterface1);
end;
现在可以清楚地看到 Tinterface1 和 Iinterface1 之间没有连接。
当使用 Tinterface1 调用 proc 时,问题就来了。这不会编译 Tinterface1 不继承 Iinterface1。
那么建议做什么?更改自动生成的库?或者当您想将 Tinterface1 传递给 proc 时,您是否有更好的想法。
这个例子是代码的简化,代码中有另一个对象需要传递给proc,但是proc只知道它的接口,这是同样的问题。
更新:com dll文件的手册似乎说proc应该是
procedure proc(param:^Tinterface1);
界面仅在 delphi 的角度。
【问题讨论】:
-
您需要发布真实代码。您是否在 typelib 查看器中查看过 typelib?文件应该显示什么?
-
您推荐使用特定类型的 lib 查看器吗?它是专有代码,不是我的。
-
即使只是使用 Delphi 附带的类型库查看器,也会向您显示结构应该是什么。 delphi ide不太可能错误地生成tlb pas
标签: delphi com interface delphi-2009