Code:
std::map<CString, CString> mapWindowsVersions
{
{ L"22631", L"23H2" },
{ L"22621", L"22H2" },
{ L"22000", L"21H2" },
{ L"19044", L"21H2" },
{ L"19043", L"21H1" },
{ L"19042", L"20H2" },
{ L"19041", L"2004" },
{ L"18363", L"1909" },
{ L"18362", L"1903" },
{ L"17763", L"1809" },
{ L"17134", L"1803" },
{ L"16299", L"1709" }
};
VARIANT vtProp{};
hres = pclsObj->Get(L"BuildNumber", 0, &vtProp, 0, 0);
strSystemInfo.AppendFormat(L" Build Number: %s\r\n", mapWindowsVersions[vtProp.bstrVal]);
VariantClear(&vtProp);
This works., I gleaned release descriptions from here. But is there a built-in way to get this description, eg: 23H2?
I don't know the answer off-the-top-of-my-head, but I know where to start looking:
winver.exe.Here's my About Windows dialog, which dutifully displays the "Version 22H2" string you're after:
winver.exein WinDbg or Ghidra or whathaveyou shows thatwinver.exejust calls intoShell32.dll!ShellAboutWto do all its actual work.AboutDlgProcto drive the About Windows dialog._InitAboutDlgto load the data (strings, text, etc) into the Dialog's labels/placeholders.HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersionregistry key and then extracts values based on some arbitrary business rules:EnableH2UIVersioningwhich controls whether the "22H2"-style release name will be displayed or not. When this istruethen the "22H2" string comes fromHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DisplayVersion, otherwise it usesHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId.DisplayVersionandReleaseIdare present, butReleaseIdcontains the incorrect/old value of "2009" - which means thatReleaseIdcannot be trusted if present.