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

#218 in Rust patterns

Download history 1982374/week @ 2024-01-18 1933002/week @ 2024-01-25 2131935/week @ 2024-02-01 2114977/week @ 2024-02-08 2107678/week @ 2024-02-15 2396947/week @ 2024-02-22 2426224/week @ 2024-02-29 2193346/week @ 2024-03-07 2179689/week @ 2024-03-14 2310833/week @ 2024-03-21 2303765/week @ 2024-03-28 2340628/week @ 2024-04-04 2446468/week @ 2024-04-11 2544464/week @ 2024-04-18 2283820/week @ 2024-04-25 2066282/week @ 2024-05-02

9,774,630 downloads per month
Used in 53,679 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