15 releases

0.53.0 Jan 7, 2025
0.52.6 Jul 3, 2024
0.52.5 Apr 12, 2024
0.52.4 Feb 28, 2024
0.0.0 Sep 9, 2022

#349 in Windows APIs

Download history 3470284/week @ 2024-10-08 3303997/week @ 2024-10-15 3146067/week @ 2024-10-22 2930142/week @ 2024-10-29 3108187/week @ 2024-11-05 3186356/week @ 2024-11-12 3183698/week @ 2024-11-19 2526044/week @ 2024-11-26 3188990/week @ 2024-12-03 3206044/week @ 2024-12-10 2825798/week @ 2024-12-17 1406352/week @ 2024-12-24 1880882/week @ 2024-12-31 3193255/week @ 2025-01-07 3241149/week @ 2025-01-14 2715976/week @ 2025-01-21

11,327,485 downloads per month
Used in 71,785 crates (23 directly)

MIT/Apache

14MB
52 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.53"

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);

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

Dependencies