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 10986/week @ 2024-01-02 12310/week @ 2024-01-09 12843/week @ 2024-01-16 12117/week @ 2024-01-23 12946/week @ 2024-01-30 12205/week @ 2024-02-06 14189/week @ 2024-02-13 14840/week @ 2024-02-20 15743/week @ 2024-02-27 14103/week @ 2024-03-05 13769/week @ 2024-03-12 13998/week @ 2024-03-19 13842/week @ 2024-03-26 13913/week @ 2024-04-02 14122/week @ 2024-04-09 12649/week @ 2024-04-16

56,929 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