c++winapiwindows-runtimewrl

Native C++ passing IIterable to WinRT


I have a Win32 app that is using WRL (Windows Runtime Template Library) to access the WinRT API.

How do I go about calling a function that takes an IIterable from native C++? My issue is obtaining something that implements IIterable or IVector.

As a concrete example, suppose I wanted to call SetDefaultMenuItems in Include\10.0.14393.0\winrt\windows.ui.input.h:

namespace ABI {
namespace Windows {
namespace UI {
namespace Input {

    MIDL_INTERFACE("A6B79ECB-6A52-4430-910C-56370A9D6B42")
    IRadialControllerConfiguration : public IInspectable
    {
        public:
            virtual HRESULT STDMETHODCALLTYPE SetDefaultMenuItems( 
            /* [in] */ __RPC__in_opt __FIIterable_1_Windows__CUI__CInput__CRadialControllerSystemMenuItemKind *buttons) = 0;
        // ...
    };
}
}
}
}

There doesn't seem to be a stock implementation of IIterable or IVector for native C++.


Solution

  • I ended up using cppwinrt to do what I wanted. With this, I was able to pass vanilla std containers, etc. to WinRT.