COM Interface as a param of WinRT ref class, how i

2019-08-07 15:47发布

问题:

How I can define this class correctly:

public ref class WICBMP sealed
{
  void Load(IWICBitmapSource ^wicBitmapSource);
};

回答1:

This is not possible. Only Windows Runtime types may be used when declaring members of a Windows Runtime interface (in this specific case, the compiler will need to generate an interface that declares your Load member function). You can't even do this if you try to define the interface in IDL.

A runtime class can implement COM interfaces that are not Windows Runtime interfaces, though. For example, see IBufferByteAccess (a COM interface), which all IBuffer (a Windows Runtime interface) implementations must implement.