Win32 APIs Now Available For More Languages

Win32 APIs are now readily accessible to C# and Rust.

Recently, Microsoft shared that it is expanding the scope of Win32 APIs support for C# and Rust through the win32metadata project. Win32metadata project is available in preview on GitHub.

Win32metadata project aims to provide a complete description of the Win32 API surface in metadata, enabling projection to any language in an automated way. Making Win32 APIs more accessible to more languages will enable you to make the most out of Windows regardless of your preferred language. 

Microsoft said that for this metadata to enable developers to call Win32 APIs idiomatically from the language of their choice, it required that language projections built on top of it. The first such language projection is C#/Win32.

C#/Win32 parses the metadata and generates the P/Invoke wrappers needed to call the APIs you want. You simply need to add a reference to the Microsoft.Windows.CsWin32 package from NuGet.org.  Then add a file called NativeMethods.txt to the root of your project with a list of Win32 functions you want to call. Once populated, C#/Win32 will create the P/Invoke wrappers for all the functions that you request, along with their dependencies.

Source: Microsoft

Microsoft said that apart from C# and Rust, it is also working on a Modern C++ projection in the open on GitHub. As these projects are early previews and under active development so are subject to change as they make progress.