22 breaking releases

new 0.53.0 Feb 22, 2024
0.52.0 Nov 15, 2023
0.51.1 Aug 17, 2023
0.49.0 Apr 17, 2023
0.0.0 Oct 18, 2021

#16 in Procedural macros

Download history 15095/week @ 2023-11-05 15322/week @ 2023-11-12 14139/week @ 2023-11-19 13923/week @ 2023-11-26 14827/week @ 2023-12-03 14417/week @ 2023-12-10 12697/week @ 2023-12-17 9600/week @ 2023-12-24 10529/week @ 2023-12-31 12781/week @ 2024-01-07 13187/week @ 2024-01-14 12306/week @ 2024-01-21 13093/week @ 2024-01-28 12937/week @ 2024-02-04 13957/week @ 2024-02-11 14287/week @ 2024-02-18

55,433 downloads per month
Used in 111 crates (6 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.1"

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

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());
    }
}

Dependencies