3 unstable releases

0.1.1 Mar 18, 2025
0.1.0 Feb 21, 2025
0.0.0 Jul 17, 2024

#387 in Windows APIs

Download history 2/week @ 2025-02-10 10227/week @ 2025-02-17 170676/week @ 2025-02-24 289872/week @ 2025-03-03 527491/week @ 2025-03-10 1118865/week @ 2025-03-17 1320774/week @ 2025-03-24 954527/week @ 2025-03-31 1039199/week @ 2025-04-07

4,474,409 downloads per month
Used in 15,238 crates (14 directly)

MIT/Apache

7KB

Linking for Windows

The windows-link crate provides the link macro that simplifies linking. The link macro is much the same as the one provided by windows-targets but uses raw-dylib and thus does not require import lib files.

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

[dependencies.windows-link]
version = "0.1"

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

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

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

No runtime deps