tree: d57f0df35e61698e21ee198ec74d96440701a3e9 [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-targets/readme.md

Import libs for Windows

The windows-targets crate includes import libs, supports semantic versioning, and optional support for raw-dylib.

Note: As of Rust 1.71, the windows-link crate should be preferred.

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

[dependencies.windows-targets]
version = "0.53"

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

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

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