Use VersionHelper API for Windows version.

This commit is contained in:
John Preston 2019-06-03 13:48:36 +03:00
parent ef364e998f
commit 271d929ad6
3 changed files with 20 additions and 13 deletions

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/win/wrapper_windows_h.h" #include "platform/win/wrapper_windows_h.h"
#include <shellapi.h> #include <shellapi.h>
#include <VersionHelpers.h>
namespace Platform { namespace Platform {
namespace { namespace {
@ -22,15 +23,20 @@ QString DeviceModel() {
} }
QString SystemVersion() { QString SystemVersion() {
switch (QSysInfo::windowsVersion()) { if (IsWindows10OrGreater()) {
case QSysInfo::WV_XP: return "Windows XP"; return "Windows 10";
case QSysInfo::WV_2003: return "Windows 2003"; } else if (IsWindows8Point1OrGreater()) {
case QSysInfo::WV_VISTA: return "Windows Vista"; return "Windows 8.1";
case QSysInfo::WV_WINDOWS7: return "Windows 7"; } else if (IsWindows8OrGreater()) {
case QSysInfo::WV_WINDOWS8: return "Windows 8"; return "Windows 8";
case QSysInfo::WV_WINDOWS8_1: return "Windows 8.1"; } else if (IsWindows7OrGreater()) {
case QSysInfo::WV_WINDOWS10: return "Windows 10"; return "Windows 7";
default: return "Windows"; } else if (IsWindowsVistaOrGreater()) {
return "Windows Vista";
} else if (IsWindowsXPOrGreater()) {
return "Windows XP";
} else {
return QSysInfo::prettyProductName();
} }
} }

View File

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <windows.ui.notifications.h> #include <windows.ui.notifications.h>
#include <Windowsx.h> #include <Windowsx.h>
#include <VersionHelpers.h>
#define min(a, b) ((a) < (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) < (b) ? (b) : (a)) #define max(a, b) ((a) < (b) ? (b) : (a))
@ -925,7 +926,7 @@ void MainWindow::psUpdateMargins() {
} }
if (!_themeInited) { if (!_themeInited) {
_themeInited = true; _themeInited = true;
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) { if (!IsWindows8OrGreater()) {
if (Dlls::SetWindowTheme != nullptr) { if (Dlls::SetWindowTheme != nullptr) {
Dlls::SetWindowTheme(ps_hWnd, L" ", L" "); Dlls::SetWindowTheme(ps_hWnd, L" ", L" ");
QApplication::setStyle(QStyleFactory::create(qsl("Windows"))); QApplication::setStyle(QStyleFactory::create(qsl("Windows")));

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "platform/win/windows_dlls.h" #include "platform/win/windows_dlls.h"
#include <VersionHelpers.h>
#include <QtCore/QSysInfo> #include <QtCore/QSysInfo>
namespace Platform { namespace Platform {
@ -76,8 +77,7 @@ void start() {
LibUxTheme = LoadLibrary(L"UXTHEME.DLL"); LibUxTheme = LoadLibrary(L"UXTHEME.DLL");
load(LibUxTheme, "SetWindowTheme", SetWindowTheme); load(LibUxTheme, "SetWindowTheme", SetWindowTheme);
auto version = QSysInfo::windowsVersion(); if (IsWindowsVistaOrGreater()) {
if (version >= QSysInfo::WV_VISTA) {
LibWtsApi32 = LoadLibrary(L"WTSAPI32.DLL"); LibWtsApi32 = LoadLibrary(L"WTSAPI32.DLL");
load(LibWtsApi32, "WTSRegisterSessionNotification", WTSRegisterSessionNotification); load(LibWtsApi32, "WTSRegisterSessionNotification", WTSRegisterSessionNotification);
load(LibWtsApi32, "WTSUnRegisterSessionNotification", WTSUnRegisterSessionNotification); load(LibWtsApi32, "WTSUnRegisterSessionNotification", WTSUnRegisterSessionNotification);
@ -86,7 +86,7 @@ void start() {
load(LibPropSys, "PropVariantToString", PropVariantToString); load(LibPropSys, "PropVariantToString", PropVariantToString);
load(LibPropSys, "PSStringFromPropertyKey", PSStringFromPropertyKey); load(LibPropSys, "PSStringFromPropertyKey", PSStringFromPropertyKey);
if (version >= QSysInfo::WV_WINDOWS8) { if (IsWindows8OrGreater()) {
LibComBase = LoadLibrary(L"COMBASE.DLL"); LibComBase = LoadLibrary(L"COMBASE.DLL");
load(LibComBase, "RoGetActivationFactory", RoGetActivationFactory); load(LibComBase, "RoGetActivationFactory", RoGetActivationFactory);
load(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference); load(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference);