Use Windows Registry instead of a static release names to builds (PR #12544)
Closes #12509
# Summary of the issue:
Currently a static Windows 10 release names to builds map is used to record Windows 10 builds to feature updates (releases). Until 21H1 there was a one-to-one correspondence between releases and builds, but it appears Version 21H2 will be represented by multiple builds:
- Windows 10: 19044
- Server 2022: 20348
- Windows 11: build 22000
Therefore this breaks the existing static map of WIN10_RELEASE_NAME_TO_BUILDS.
"21H2" can not be the key for 19044, 20348, and 22000.
# Description of how this pull request fixes the issue:
- Replace WIN10_RELEASE_NAME_TO_BUILDS with the inverse mapping (_BUILDS_TO_RELEASE_NAMES), which is how it is used anyway.
- Allow class WinVersion to be constructed with an optional releaseName, if it is missing look up the name in static map.
- For the "currently running" version of Windows, try to look up the name via the registry if possible. Fall back to the static map.
Note:
- Since Version 1511, Windows Registry holds release name which corresponds to builds (e.g. 1511 = 10586, 20H2 = 19042), housed inside a "Release Id" key.
- Starting with Version 20H2, a separate "DisplayVersion" key is used to announce public release name.
- In Windows Insider Preview builds, dev channel has display version of "Dev", making it even easier to determine what kind of build a user is running.
- This tradition continues with Windows 11 and Server 2022, with Registry recording "21H2", which makes sense given their projected release period.