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

#337 in Rust patterns

Download history 3192130/week @ 2024-08-17 3404721/week @ 2024-08-24 2973487/week @ 2024-08-31 3347010/week @ 2024-09-07 2861552/week @ 2024-09-14 3183518/week @ 2024-09-21 3260751/week @ 2024-09-28 3378855/week @ 2024-10-05 3552342/week @ 2024-10-12 3129624/week @ 2024-10-19 2986260/week @ 2024-10-26 3099739/week @ 2024-11-02 3105756/week @ 2024-11-09 3199683/week @ 2024-11-16 2586990/week @ 2024-11-23 2568091/week @ 2024-11-30

11,981,987 downloads per month
Used in 68,925 crates (20 directly)

MIT/Apache

7MB
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