KEMBAR78
Add query for OS revision number to `windows-version` crate by kennykerr · Pull Request #3752 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@kennykerr
Copy link
Collaborator

The windows-version crate provides reliable operating system version information without the need for application manifest files. The OsVersion struct provides the traditional OS version information for major, minor, service pack, and build number. Unfortunately, recent Windows versioning conventions have largely dropped the use of minor and service pack versions while adding a new revision number as you can see when you run commands like winver.exe or cmd.exe.

This update adds a revision function to the windows-version crate that lets you reliably get the same version information used by these OS tools. Here's a simple example that mimics what cmd.exe displays:

fn main() {
    let current = windows_version::OsVersion::current();

    let major = current.major;
    let minor = current.minor;
    let build = current.build;
    let revision = windows_version::revision();

    println!("Microsoft Windows [Version {major}.{minor}.{build}.{revision}]");
}

@kennykerr kennykerr merged commit 2b37e78 into master Sep 9, 2025
28 checks passed
@kennykerr kennykerr deleted the version-revision branch September 9, 2025 19:00
This was referenced Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants