Skip to content

microsoft/windows-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2,313 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

windows-rs lets you call Windows APIs β€” past, present, and future β€” directly from Rust. It is not a single crate but a family of them, from low-level API access to high-level declarative UI. This page helps you find the right crate for the job; each crate's own documentation then covers how to use it, with examples.

A family of crates

Most of these crates are small and focused β€” string types, error handling, the registry, collections, and so on β€” and you depend only on what you actually use. For broad, exploratory access to the entire Windows API surface, the windows and windows-sys crates project everything past, present, and future, gated behind per-namespace features.

For most projects, prefer the focused crates below, and generate a minimal, project-specific binding with windows-bindgen for any additional APIs you need.

Choosing your crates

Start with what you are trying to do and add the smallest crate that covers it. Follow the link for usage and examples.

If you need… Use
Windows error handling (HRESULT, Error, Result) windows-result
Windows string types and macros (HSTRING, PCWSTR, h!, w!, s!) windows-strings
COM/WinRT type support (IUnknown, the Interface trait, cast, GUID) windows-core
To declare or implement a COM/WinRT interface #[interface] / #[implement]
Stock WinRT collections (IVector, IMap, …) windows-collections
WinRT values (IReference<T>, TimeSpan, DateTime) windows-reference, windows-time
Graphics math (vectors, matrices) windows-numerics
WinRT async bridged to Rust futures windows-future
The Win32 thread pool windows-threading
The Windows registry windows-registry
To author a Windows service windows-services
The OS version at runtime windows-version
To link C-style functions without import libs (link!, raw-dylib) windows-link
To generate your own focused bindings windows-bindgen
A declarative WinUI 3 UI, 2D graphics, a WebView, or a window windows-reactor, windows-canvas, windows-webview, windows-window

Crates

The full categorized index follows. Each crate has one page under crates/ covering both usage and internals β€” how the crate is built and maintained (the tool_bindings / tool_reactor / tool_package codegen pipeline, generated files, and conventions). Each crate's own readme.md is the user-facing introduction with a quick example, and the per-crate page links to it. Item-level API reference is the generated rustdoc on docs.rs, linked from every page.

Core & error handling

Crate Description
windows-core Fundamental COM and Windows type support.
windows-result Windows error handling and propagation.
windows-strings Windows string interop types and macros.

Values & collections

Crate Description
windows-numerics Graphics math types (vectors and matrices).
windows-collections Stock WinRT collection types.
windows-reference Stock IReference<T> implementation.
windows-time WinRT TimeSpan and DateTime.

Async & threading

Crate Description
windows-future WinRT async bridged to Rust futures.
windows-threading Safe wrapper over the Win32 thread pool.

System services

Crate Description
windows-registry Safe Windows registry access.
windows-services Author Windows services in Rust.
windows-version Query the Windows version at runtime.

COM macros & linking

Crate Description
windows-implement #[implement] proc macro for COM/WinRT.
windows-interface #[interface] proc macro for COM interfaces.
windows-link Raw-dylib import support (link!).
windows-targets Import libs for older compilers.

UI & graphics

Crate Description
windows-reactor Declarative UI library backed by WinUI 3.
windows-canvas 2D graphics built on Direct2D.
windows-webview Safe wrapper around the WebView2 browser control.
windows-window Minimal window creation and message loop.
windows-animation Wrapper around the Windows Animation Manager.
windows-reactor-setup Windows App Runtime installer for reactor apps.

Codegen & metadata tooling

Crate Description
windows-bindgen Code generator for Windows metadata.
windows-metadata Low-level ECMA-335 metadata library.
windows-rdl RDL parser and ECMA-335 generator.
riddle Windows metadata compiler.
cppwinrt Bundles the C++/WinRT compiler.

Full Windows API projection

These crates project the entire Windows API surface. For new projects, prefer a focused binding generated with windows-bindgen, or compose the smaller crates above.

Crate Description
windows Safer projection of C-style, COM, and WinRT APIs.
windows-sys Zero-overhead raw bindings for C-style Windows APIs.

About

Rust for Windows

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
license-apache-2.0
MIT
license-mit

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors