1
0
Fork 0
firefox/third_party/rust/windows-link
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00
..
src Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
.cargo-checksum.json Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
Cargo.lock Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
Cargo.toml Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
license-apache-2.0 Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
license-mit Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
readme.md Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00

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