From af00ba9e5bd2133fcd66d1a682d856b707628b3b Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Thu, 29 Sep 2022 00:31:42 +0200 Subject: [PATCH] +fix: Win10/11 build number to name mapping --- src/Helpers.c | 49 ++++------------------------------------- src/Notepad3.c | 6 ++--- src/Version.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 48 deletions(-) diff --git a/src/Helpers.c b/src/Helpers.c index 743d9ec6a..dca72b02c 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -16,13 +16,13 @@ * * *******************************************************************************/ -#include "Helpers.h" - #include #include #include #include +#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); } } diff --git a/src/Notepad3.c b/src/Notepad3.c index 274958aae..4750fc273 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -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; diff --git a/src/Version.h b/src/Version.h index 940c941e9..4e6bad044 100644 --- a/src/Version.h +++ b/src/Version.h @@ -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