[fpc-pascal] Instances of interfaces ?
Michael Van Canneyt
michael at freepascal.org
Fri Oct 10 11:32:23 CEST 2014
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.
More information about the fpc-pascal
mailing list