Function winsafe::VarQueryValue[][src]

pub unsafe fn VarQueryValue<T>(
    block: &[u8],
    sub_block: &str
) -> WinResult<(*const T, u32)>
Expand description

VarQueryValue function.

Note: The returned pointer and size vary according to lpSubBlock. If you set it wrong, you’re likely to cause a buffer overrun.

This function is rather tricky, consider using ResourceInfo.

Examples

Reading version information from resource:

use winsafe::{HINSTANCE, VS_FIXEDFILEINFO};
use winsafe::{GetFileVersionInfo, VarQueryValue};

let exe_name = HINSTANCE::NULL.GetModuleFileName()?;
let res_buf = GetFileVersionInfo(&exe_name)?;

let (pvsf, sz_data) = unsafe {
    VarQueryValue::<VS_FIXEDFILEINFO>(&res_buf, "\\")?
};

let ver = unsafe { &*pvsf }.dwFileVersion();
println!("Version {}.{}.{}.{}",
    ver[0], ver[1], ver[2], ver[3]);