tree: c7afffeec9e22e7357d9388cf1167fde4dd49af9 [path history] [tgz]
  1. src/
  2. .android-checksum.json
  3. .cargo-checksum.json
  4. .cargo_vcs_info.json
  5. Android.bp
  6. Cargo.lock
  7. Cargo.toml
  8. Cargo.toml.orig
  9. cargo_embargo.json
  10. license-apache-2.0
  11. METADATA
  12. MODULE_LICENSE_APACHE2
  13. readme.md
  14. TEST_MAPPING
crates/windows-link/readme.md

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