#os-version #version #nt #winapi #os #windows

no-std nt_version

Queries the major, minor and build version of Windows (NT) efficiently

1 unstable release

0.1.3 Jan 1, 2020
0.1.2 Dec 7, 2019
0.1.1 Dec 7, 2019
0.1.0 Dec 7, 2019

#219 in Windows APIs

Download history 22/week @ 2024-07-22 13/week @ 2024-07-29 17/week @ 2024-08-05 16/week @ 2024-08-12 9/week @ 2024-08-19 9/week @ 2024-08-26 14/week @ 2024-09-02 17/week @ 2024-09-09 59/week @ 2024-09-16 61/week @ 2024-09-23 21/week @ 2024-09-30 7/week @ 2024-10-14 8/week @ 2024-10-21 53/week @ 2024-10-28 35/week @ 2024-11-04

103 downloads per month

Unlicense

7KB

Build Status Crates.io Docs.rs License

nt_version

Queries the major, minor, and build version of Windows (NT) efficiently with usage of undocumented NTDLL functions. Needs a minimum version of NT 5.1 (Windows XP or above). This crate is no_std.

nt_version = "0.1"

If building fails with a linker error, you're missing ntdll.lib from your system. It doesn't come on older versions of Windows with the SDK and you need to install the DDK.

Alternatively, enable the fallback feature which queries the function pointer at runtime (but is slower):

nt_version = { version = "0.1", features = ["fallback"] }

Usage

It only has one function: get, and it's recommended you use it explicitly:

fn main() {
    let (major, minor, build) = nt_version::get();
    println!("NT Version v{}.{}.{}", major, minor, build);
}

This returns the NTDLL version, which has this numbering system.

Why?

Microsoft deprecated GetVersionEx back in Windows 8.1 in favour of functions such as "IsWindows8Point1OrGreater" and there's not really a good way to just get an OS version now. You can still use NetWkstaGetInfo from lmwksta.h if you just want the OS version without any build numbers, but it's much slower and allocates a WKSTA_INFO_100 chunk which you have to deallocate yourself, containing excess info your like PC name as a windows wide-string. Not very ideal.

Dependencies

~175KB