Expand description
§minwindef.h
macros for use in Rust with the windows-rs and windows-sys crates
This module defines equivalents to the macros defined in Include/<version>/shared/minwindef.h as part of the Windows SDK. These macros serve to (un)pack numeric values into and from larger numeric types.
Besides the existing #define
s, this module adds a couple functions useful for those working
with 64-bit integers and pointers:
lodword
andhidword
to get the lower and higher 32 bits from themmakelonglong
to pack two 32-bit ints into a 64-bit int. These were added because they’re useful for working with e.g.CreateFileMapping*
functions.
Lastly some additional methods were added for splitting and returning both values at once. Consider them syntactical sugar over the others, as that really is all they are. They just return a tuple containing (in order) the low order and high order components. This is achieved by just calling both of those functions one after the other.
use windows_ext::minwindef::*;
// existing minwindef.h macros:
let full: u32 = 9548625;
let lo1 = loword(full);
let hi1 = hiword(full);
// convenience wrapper:
let full: u32 = 9548625;
let (lo2, hi2) = splitdword(full);
assert_eq!(lo1, lo2);
assert_eq!(hi1, hi2);
Modules§
- ext
- This module provides extension traits that expose the freestanding functions from minwindef directly on the respective types.
Functions§
- hibyte
- Get the high order byte from a word (u16)
- hidword
- Get the high order double word from a u64
- hiword
- Get the high order word as u16
- lobyte
- Get the low order byte from a word (u16)
- lodword
- Get the low order double word from a u64
- loword
- Get the low order word as u16
- makelong
- Turn two words into a dword/long docs are somewhat weird, the macro is named “MAKELONG” but returns a DWORD?
- makelonglong
- Not part of the standard macros, but a logical step to accommodate 64-bit Named after the underlying C datatype, in Win32 terms this would be a QWORD
- makeword
- Turn two bytes into a word
- splitdword
- Split a single dword (
u32
) in both of its words (u16
s) ordered (low, high) - splitqword
- Split a single dword (
u32
) in both of its words (u16
s) ordered (low, high) - splitword
- Split a single word (
u16
) in both of its bytes (u8
s) ordered (low, high)