+fix: Win10/11 build number to name mapping

This commit is contained in:
METANEOCORTEX\Kotti 2022-09-29 00:31:42 +02:00
parent e8ce088751
commit af00ba9e5b
3 changed files with 66 additions and 48 deletions

View File

@ -16,13 +16,13 @@
* *
*******************************************************************************/
#include "Helpers.h"
#include <shlobj.h>
#include <shellapi.h>
#include <ctype.h>
#include <wchar.h>
#include "Helpers.h"
#include "PathLib.h"
#include "Edit.h"
#include "Encoding.h"
@ -31,6 +31,7 @@
#include "Dialogs.h"
#include "Config/Config.h"
#include "DarkMode/DarkMode.h"
#include "Version.h"
#pragma warning(push)
#pragma warning(disable : 4201) // union/struct w/o name
@ -218,47 +219,6 @@ static void _GetTrueWindowsVersion()
// ----------------------------------------------------------------------------
#endif
// ----------------------------------------------------------------------------
// https://docs.microsoft.com/en-us/windows/release-health/ (Windows releases health)
// https://docs.microsoft.com/en-us/windows/release-health/release-information (Windows 10)
// https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information (Windows 11)
// https://docs.microsoft.com/en-us/windows/release-health/windows-server-release-info (Windows Server)
// https://docs.microsoft.com/en-us/windows-insider/flight-hub/ (Windows Insider Preview Builds)
// ----------------------------------------------------------------------------
static LPCWSTR _Win10BuildToReleaseId() {
static LPCWSTR _wchpReleaseID = L"1507"; // <= 10240
DWORD const build = GetWindowsBuildNumber(NULL, NULL);
if (build > 19043) {
_wchpReleaseID = L"21H2";
} else if (build > 19042) {
_wchpReleaseID = L"21H1";
} else if (build > 19041) {
_wchpReleaseID = L"20H2";
} else if (build > 18363) {
_wchpReleaseID = L"2004";
} else if (build > 18362) {
_wchpReleaseID = L"1909";
} else if (build > 17763) {
_wchpReleaseID = L"1903 [EoS]";
} else if (build > 17134) {
_wchpReleaseID = L"1809";
} else if (build > 16299) {
_wchpReleaseID = L"1803 [EoS]";
} else if (build > 15063) {
_wchpReleaseID = L"1709 [EoS]";
} else if (build > 14393) {
_wchpReleaseID = L"1703 [EoS]";
} else if (build > 10586) {
_wchpReleaseID = L"1607";
} else if (build > 10240) {
_wchpReleaseID = L"1511 [EoS]";
}
return _wchpReleaseID;
}
// ----------------------------------------------------------------------------
void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr)
{
@ -283,8 +243,7 @@ void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr)
if (IsWindows10OrGreater()) {
WCHAR win10ver[80] = { L'\0' };
StringCchPrintf(win10ver, COUNTOF(win10ver), L" Version %s (Build %lu)",
_Win10BuildToReleaseId(), GetWindowsBuildNumber(NULL, NULL));
StringCchPrintf(win10ver, COUNTOF(win10ver), L" Version %s (Build %lu)", _Win10BuildToReleaseId(build), GetWindowsBuildNumber(NULL, NULL));
StringCchCat(szVersionStr, cchVersionStr, win10ver);
}
}

View File

@ -3599,8 +3599,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam)
//=============================================================================
//
// MsgContextMenu() - Handles WM_CONTEXTMENU
//
// MsgContextMenu() - Handles WM_CONTEXTMENU and SCN_MARGINRIGHTCLICK
//
LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
@ -9142,7 +9141,8 @@ void ParseCommandLine()
Path_Reset(pthAddFile, lpFileBuf);
Path_NormalizeEx(pthAddFile, Paths.WorkingDirectory, true, true);
Path_QuoteSpaces(pthAddFile, false);
s_lpFileList[s_cFileList++] = StrDupW(Path_Get(pthAddFile)); // LocalAlloc()
s_lpFileList[s_cFileList] = StrDupW(Path_Get(pthAddFile)); // LocalAlloc()
s_cFileList += 1;
}
Path_Release(pthAddFile);
bContinue = false;

View File

@ -71,6 +71,65 @@
// ============================================================================
// ----------------------------------------------------------------------------
// https://docs.microsoft.com/en-us/windows/release-health/ (Windows releases health)
// https://docs.microsoft.com/en-us/windows/release-health/release-information (Windows 10)
// https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information (Windows 11)
// https://docs.microsoft.com/en-us/windows/release-health/windows-server-release-info (Windows Server)
// https://docs.microsoft.com/en-us/windows-insider/flight-hub/ (Windows Insider Preview Builds)
// ----------------------------------------------------------------------------
inline LPCWSTR _Win10BuildToReleaseId(const DWORD build)
{
static LPCWSTR lpcReleaseID = L"unknown";
if (build >= 19045) {
lpcReleaseID = L"22H2";
}
else if (build >= 19044) {
lpcReleaseID = L"22H1";
}
else if (build >= 19043) {
lpcReleaseID = L"21H1";
}
else if (build >= 19042) {
lpcReleaseID = L"20H2";
}
else if (build >= 19041) {
lpcReleaseID = L"20H1";
}
else if (build >= 18363) {
lpcReleaseID = L"19H2";
}
else if (build >= 18362) {
lpcReleaseID = L"19H1";
}
else if (build >= 17763) {
lpcReleaseID = L"1809";
}
else if (build >= 17134) {
lpcReleaseID = L"1803";
}
else if (build >= 16299) {
lpcReleaseID = L"1709";
}
else if (build >= 15063) {
lpcReleaseID = L"1703";
}
else if (build >= 14393) {
lpcReleaseID = L"1607";
}
else if (build >= 10586) {
lpcReleaseID = L"1511";
}
else if (build >= 10240) {
lpcReleaseID = L"1507";
}
return lpcReleaseID;
}
// ============================================================================
// Compiler specific
#undef VER_CPL