When developing for Windows, what are the (dis)advantages of winapi vs. windows crate?

So there's winapi from a fellow Rustacean and then there is windows.

In order not to saddle a dead horse, which one should I prefer? What are the advantages/disadvantages?

I already know that the windows/windows-sys crates use the win32metadata to create what Microsoft calls a "language projection" to Rust. And that sounds somewhat enticing, especially since I plan to also use certain undocumented API functions and I'm pondering to use the same approach for that. On the other hand C++/WinRT is a behemoth and that's where the Rust "language projection" from Microsoft originates.

However, perhaps I am missing out on something if I don't take a closer look at winapi.

Any insights you can give would be appreciated.

Basically winapi was made by some random person way back. Then several years later, Microsoft released the windows-sys crate which is an official crate owned by Microsoft that does roughly the same things as winapi.


The main differences are

  • winapi is version 0.3.x since 2018, whereas windows and windows-sys are still releasing 0.x bumps regularly.
  • winapi is an essentially by-hand translation of the Windows headers, whereas the windows-sys crate is (almost) entirely generated from the source-of-truth IDL describing the Windows OS APIs.
  • winapi is a sys-level description of the OS APIs, at the same level as windows-sys. The windows crate is also primarily generated, but contains some helpers which are authored specifically for Rust to adapt API into a more Rust-idiomatic and useful shape (e.g. using Result, implementing Drop, and other niceties).

If you're happy with the latest and greatest at the cost of some updating churn, use the windows crate. If stability is more important, stick to winapi for the time being.

If you need COM or WinRT access, you might prefer the windows crate, especially if you need to define and/or implement COM interfaces, due to it providing (attribute) macros to help with the mapping.

This will change if/when the windows crate releases a 1.0 version (or otherwise Microsoft commits to some stability to the projected API). At that point, I will personally be recommending everyone to adopt the windows crate.


I feel this is unfairly dismissive. WindowsBunny / @retep998 was a fairly prominent, respected Rustacean back in the day, for his work making Rust work well on Windows, and was one of two contributors given the Friend of the Tree award[1] for such work. At one point it was said that WindowsBunny "IS Rust on Windows".[2]

  1. a now-defunct Mozilla tradition ↩ī¸Ž

  2. likely not an exact quotation, as I'm not at my computer that has my IRC logs ↩ī¸Ž


Three years ago the windows crate did not exist. Microsoft, as far as I know, had essentially zero interest. About 1.5 years ago the windows crate was unusable.

I am very grateful to @retep998 for the winapi crate. That thing literally carved out a niche for me at my current place of employment. I still prefer it over the windows crate.