How to call a Windows WinRT C# API, or C++ API from GDNative?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KBS

Hi! We’re trying to call a Windows WinRT API, specifically the Windows.Media.SpeechSynthesis.SpeechSynthesizer class.

Method A: going the C# route.
This C# .NET class is not implemented in Mono. Is it possible to call a .NET class (that seems to require the WinRT runtime, though I’m not sure) from Godot_Mono, and if yes, how?

Method B: going the GDNative and C++ Route.
While the class documentation mentions C++ examples, they’re confusing because they use Microsoft’s C++/CX:

Additionally, we lack the knowledge around the seemingly pretty complex preconditions before being able to call these Windows APIs from a non-UWP C++ project. But supposedly it should be possible to call these APIs from a Win32 project, so I guess it should be possible from Godot too.

Does anyone happen to have a working sample of a call to any Windows WinRT API?

Or does anyone have any pointers to a relevant tutorial that actually applies to the specific case of a WinRT API being called from a plain C++ project?

Does it have to be C++? If you didn’t know, the engine does support C#. If speed and/or efficiency are not much of a problem, consider using the C# API.

Ertain | 2021-02-26 19:59

You’re right, I completely forgot that at first we researched a way to call this .NET C# class from Godot_Mono and couldn’t find a solution. I’ve edited the question.

KBS | 2021-02-26 20:08