25 breaking releases

0.56.0 Apr 12, 2024
0.55.0 Mar 6, 2024
0.54.0 Feb 27, 2024
0.52.0 Nov 15, 2023
0.0.0 Oct 18, 2021

#46 in Procedural macros

Download history 12065/week @ 2024-01-22 12862/week @ 2024-01-29 12601/week @ 2024-02-05 13743/week @ 2024-02-12 14747/week @ 2024-02-19 15382/week @ 2024-02-26 14329/week @ 2024-03-04 14073/week @ 2024-03-11 13800/week @ 2024-03-18 14148/week @ 2024-03-25 13708/week @ 2024-04-01 13812/week @ 2024-04-08 15246/week @ 2024-04-15 17377/week @ 2024-04-22 17639/week @ 2024-04-29 17366/week @ 2024-05-06

68,907 downloads per month
Used in 114 crates (7 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.56"

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