After importing into delphi the com dll file, the delphi in turn generated a lib_tlb.pas file.
Inspecting the file it shows
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;
Now its clear to see that there is no connection between Tinterface1 and Iinterface1.
The problem comes when one calls proc with an Tinterface1. this will not compile Tinterface1 does not inheritce Iinterface1.
So what suggested to do? change the lib that is auto generated? or do you have a better idea of what to do when wanting to pass Tinterface1 to proc.
The example is a simplification of the code, in the code there is anther object that needs to be the one to be passed to proc, however that proc knows only its interface, which is the same problem.
update: as it seems the manual of the com dll file, says that proc should be
procedure proc(param:^Tinterface1);
where the interface is only in delphi point of view.
TInterface1.Proc()is expecting a pre-existingIInterface1object to be passed to it as input. UseCointerface1.Create()to create that object, eg:Tinterface1is aTOleServerdescendant that does not directly inherit fromIinterface1(but it does wrap anIinterface1internally), so you have to cast it whenever you want to pass it where anIinterface1is expected, eg: