27 breaking releases

0.58.0 Jul 3, 2024
0.56.0 Apr 12, 2024
0.55.0 Mar 6, 2024
0.52.0 Nov 15, 2023
0.0.0 Oct 18, 2021

#57 in Procedural macros

Download history 13913/week @ 2024-04-02 14122/week @ 2024-04-09 15880/week @ 2024-04-16 17277/week @ 2024-04-23 17323/week @ 2024-04-30 17776/week @ 2024-05-07 22477/week @ 2024-05-14 19980/week @ 2024-05-21 18481/week @ 2024-05-28 19725/week @ 2024-06-04 18939/week @ 2024-06-11 20310/week @ 2024-06-18 16925/week @ 2024-06-25 17877/week @ 2024-07-02 17568/week @ 2024-07-09 16108/week @ 2024-07-16

71,637 downloads per month
Used in 111 crates (4 directly)

MIT/Apache

8.5MB
12K SLoC

Contains (DOS exe, 24MB) default/Windows.Win32.winmd, (Windows exe, 7.5MB) default/Windows.winmd, (DOS exe, 1MB) default/Windows.Wdk.winmd

Generate Rust bindings for Windows

The windows-bindgen crate automatically generates Rust bindings from Windows metadata.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-targets]
version = "0.52"

[dev-dependencies.windows-bindgen]
version = "0.58"

Generates Rust bindings in a build script or test as needed:

#[test]
fn bindgen() {
    let args = [
        "--out",
        "src/bindings.rs",
        "--config",
        "flatten",
        "--filter",
        "Windows.Win32.System.SystemInformation.GetTickCount",
    ];

    windows_bindgen::bindgen(args).unwrap();
}

mod bindings;

fn main() {
    unsafe {
        println!("{}", bindings::GetTickCount());
    }
}

lib.rs:

Learn more about Rust for Windows here: https://github.com/microsoft/windows-rs

Dependencies