I'd like to make dynamic (i.e. reflection-based) calls to WinRT objects, from C or C++. I will assume that I have winmd files available at run-time, so that I can find out what the methods are and what parameters they take.
In OLE Automation, IDispatch was then available to make the actual calls. However, WinRT objects don't support IDispatch. How can I then make calls? Do I need some kind of FFI library that will allow to dynamically pass the parameters, according to the COM calling convention of the processor? Or do I really need "static" class/struct declarations (for C/C++)?
Edit: The target system is a metro-style app. That precludes solutions involving banned APIs.
It is certainly possible to build what you're describing - under the covers that's exactly what the Chakra Javascript engine does with winrt metadata and is similar to what the CLR does. Both of these language projections discover the APIs at runtime and build up the low level assembly to make this happen.
It's a lot of work and isn't particularly pleasant but it's absolutely technically possible. The windows metadata contains all the information needed to create stubs for the APIs and structures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With