3 unstable releases

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

#814 in Rust patterns

Download history 7/week @ 2024-12-09 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 1036192/week @ 2025-03-17

2,027,697 downloads per month
Used in 7,072 crates (12 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