项目作者: notviri

项目描述 :
Queries Windows (NT) major/minor/build version
高级语言: Rust
项目地址: git://github.com/notviri/nt_version.git
创建时间: 2019-12-07T07:15:51Z
项目社区:https://github.com/notviri/nt_version

开源协议:The Unlicense

下载


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.

  1. 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):

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

Usage

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

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

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.