On Fri, 10 Oct 2014, Adriaan van Os wrote:

Section 7.1 Definition in Chapter 7 Interfaces of the FreePascal Language Reference says

"Instances of interfaces cannot be created directly: instead, an instance of a class implementing the interface must be created."

However, I assume that FreePascal classes (inheriting from interfaces) are (unlike C++ classes) not binary compatible (on Win32) with interfaces ? In other words, when I need to pass an instance of an interface to Win32 COM, I have to call CoCreateInstance ?

No, you can pass the interface pointer directly:

MyIntf : IMyInterface;

begin
  MyIntf := MyClassInstance as IMyInterface;
end;

Then pass on MyIntf.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to