From 1d2a18929ad656ff9aa845ea708f57bd5e7416bb Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Sep 2021 18:33:53 +0300 Subject: [PATCH] Use QOperatingSystemVersion. --- .../win/notifications_manager_win.cpp | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp index b8d8f8ae0..b834c14ed 100644 --- a/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp +++ b/Telegram/SourceFiles/platform/win/notifications_manager_win.cpp @@ -21,6 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "windows_quiethours_h.h" +#include + #include #include @@ -261,21 +263,13 @@ DWORD QuietHoursValue = 0; [[nodiscard]] bool UseQuietHoursRegistryEntry() { static const bool result = [] { - // Taken from QSysInfo. - OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0,{ '\0' } }; - if (const auto library = GetModuleHandle(L"ntdll.dll")) { - using RtlGetVersionFunction = NTSTATUS(NTAPI*)(LPOSVERSIONINFO); - const auto RtlGetVersion = reinterpret_cast( - GetProcAddress(library, "RtlGetVersion")); - if (RtlGetVersion) { - RtlGetVersion(&result); - } - } + const auto version = QOperatingSystemVersion::current(); + // At build 17134 (Redstone 4) the "Quiet hours" was replaced // by "Focus assist" and it looks like it doesn't use registry. - return (result.dwMajorVersion == 10 - && result.dwMinorVersion == 0 - && result.dwBuildNumber < 17134); + return (version.majorVersion() == 10) + && (version.minorVersion() == 0) + && (version.microVersion() < 17134); }(); return result; }