13 releases

0.52.5 Apr 12, 2024
0.52.4 Feb 28, 2024
0.52.0 Nov 15, 2023
0.48.1 Jun 28, 2023
0.0.0 Sep 9, 2022

#212 in Rust patterns

Download history 2098745/week @ 2024-02-05 2120049/week @ 2024-02-12 2242386/week @ 2024-02-19 2416572/week @ 2024-02-26 2300041/week @ 2024-03-04 2163493/week @ 2024-03-11 2235546/week @ 2024-03-18 2304018/week @ 2024-03-25 2363608/week @ 2024-04-01 2340133/week @ 2024-04-08 2463741/week @ 2024-04-15 2508156/week @ 2024-04-22 2354920/week @ 2024-04-29 2415873/week @ 2024-05-06 2526846/week @ 2024-05-13 2440723/week @ 2024-05-20

9,867,663 downloads per month
Used in 54,857 crates (12 directly)

MIT/Apache

8.5MB

Import libs for Windows

The windows-targets crate includes import libs, supports semantic versioning, and optional support for raw-dylib.

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

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

Use the link macro to define the external functions you wish to call:

windows_targets::link!("kernel32.dll" "system" fn SetLastError(code: u32));
windows_targets::link!("kernel32.dll" "system" fn GetLastError() -> u32);

fn main() {
    unsafe {
        SetLastError(1234);
        assert_eq!(GetLastError(), 1234);
    }
}

lib.rs:

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

Dependencies