14 releases

0.52.6 Jul 3, 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

#334 in Rust patterns

Download history 2940175/week @ 2024-07-29 2998381/week @ 2024-08-05 3159879/week @ 2024-08-12 3151092/week @ 2024-08-19 3366686/week @ 2024-08-26 3141558/week @ 2024-09-02 3222628/week @ 2024-09-09 2827865/week @ 2024-09-16 3223175/week @ 2024-09-23 3325891/week @ 2024-09-30 3523940/week @ 2024-10-07 3320932/week @ 2024-10-14 3133243/week @ 2024-10-21 2954424/week @ 2024-10-28 3106117/week @ 2024-11-04 3052365/week @ 2024-11-11

12,407,089 downloads per month
Used in 67,818 crates (20 directly)

MIT/Apache

8MB
51 lines

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