| Crates.io | windows-link |
| lib.rs | windows-link |
| version | 0.2.0 |
| created_at | 2024-07-17 14:18:37.425755+00 |
| updated_at | 2025-09-04 20:18:34.677915+00 |
| description | Linking for Windows |
| homepage | |
| repository | https://github.com/microsoft/windows-rs |
| max_upload_size | |
| id | 1306222 |
| size | 17,121 |
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.2"
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);
}