This article is more than 1 year old

The API that will not die: Microsoft opens crypt to unleash Win32 on Rust

Going low-level with C# and more

The Win32 API is being opened up to more languages by Microsoft via the win32metadata project.

The Windows API exposes large chunks of the Windows operating system to programmers. If you code in C or C++, the API calls are "readily accessible," according to Microsoft.

Anything else usually requires some sort of wrapper. An example of this is P/Invoke, which is intended to service C# developers (although it now points users to "a new, preferred approach for Win32" – Microsoft's win32metadata project.)

Microsoft's aim, as custodian of the Windows SDK, is to "make achieving broad and sustainable API coverage across languages a reality." In other words, it wants a one-stop shop for these API calls using whatever language a developer cares to bring to the table. Eventually.

As one would expect, the first language projection is C#/Win32, built with the assistance of Andrew Arnott of the P/Invoke project.

Interestingly, a Rust language projection is also in progress, allowing users to hit the Windows API directly from the metadata "as if they were just another Rust module."

On top of this, Microsoft is working on a modern C++ projection, and a look at the roadmap has the Win32 metadata packaged published to NuGet.org for the latest Windows SDK version in time for the company's Build 2021 event in May this year.

The Windows API itself (both in Win16 and Win32 guise) has long been a fixture for those targeting the Windows operating system. A dog-eared and decades-old copy of Dan Appleman's Visual Basic Programmers Guide to Win32 API likely decorates more than a few bookshelves, bookended by an additional tome or two by Charles Petzold. Works by Petzold, if you have some extra reading time, really drive home the potential horrors that await a careless coder seeking to prod the weirder corners of the operating system.

At the last Build, back in May 2020, Microsoft kicked off Project Reunion, a recognition that despite multiple attempts to replace the Win32 API with something fresher (WinRT and UWP spring to mind), Windows developers still needed those low-level calls.

The win32metadata project remains in a preview state at the moment. The publishing of the Win32 metadata package with all supported Windows SDK versions, as well as the publication of C#, C++, and Rust projections, is planned for the end of 2021. Other languages will follow in 2022 "based on demand." ®

More about

TIP US OFF

Send us news


Other stories you might like