From f7384a43aaf455f6078074d4f3d557e1019e1cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:53:12 +0800 Subject: [PATCH] w732 --- .../LunaTranslator/winsharedutils.py | 5 +--- plugins/winsharedutils/theme.cpp | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/LunaTranslator/LunaTranslator/winsharedutils.py b/LunaTranslator/LunaTranslator/winsharedutils.py index 1938ed17..99866a5e 100644 --- a/LunaTranslator/LunaTranslator/winsharedutils.py +++ b/LunaTranslator/LunaTranslator/winsharedutils.py @@ -316,10 +316,7 @@ _SetTheme.argtypes = HWND, c_bool, c_int def SetTheme(hwnd, dark, backdrop): - try: # win7 x86 crash unknown why - _SetTheme(hwnd, dark, backdrop) - except: - pass + _SetTheme(hwnd, dark, backdrop) showintab = utilsdll.showintab diff --git a/plugins/winsharedutils/theme.cpp b/plugins/winsharedutils/theme.cpp index 90fd6a0a..b422d0d1 100644 --- a/plugins/winsharedutils/theme.cpp +++ b/plugins/winsharedutils/theme.cpp @@ -1,6 +1,28 @@ #include "define.h" // https://github.com/Blinue/Xaml-Islands-Cpp/blob/main/src/XamlIslandsCpp/XamlWindow.h +static uint32_t GetOSversion() noexcept +{ + HMODULE hNtDll = GetModuleHandle(L"ntdll.dll"); + if (!hNtDll) + { + return 0; + } + + auto rtlGetVersion = (LONG(WINAPI *)(PRTL_OSVERSIONINFOW))GetProcAddress(hNtDll, "RtlGetVersion"); + if (rtlGetVersion == nullptr) + { + // assert(false); + return 0; + } + + RTL_OSVERSIONINFOW version{}; + version.dwOSVersionInfoSize = sizeof(version); + rtlGetVersion(&version); + + return version.dwMajorVersion; +} + static uint32_t GetOSBuild() noexcept { HMODULE hNtDll = GetModuleHandle(L"ntdll.dll"); @@ -22,7 +44,6 @@ static uint32_t GetOSBuild() noexcept return version.dwBuildNumber; } - struct Win32Helper { struct OSVersion @@ -134,6 +155,9 @@ DECLARE void _SetTheme( bool dark, int backdrop) { + // printf("%d %d\n",GetOSversion(),GetOSBuild()); + if (GetOSversion() <= 6)//win7 x32 DwmSetWindowAttribute会崩,直接禁了反正没用。不知道win8怎么样。 + return; // auto _isBackgroundSolidColor = backdrop == WindowBackdrop::SolidColor; // if (Win32Helper::GetOSVersion().Is22H2OrNewer() && // _isBackgroundSolidColor != (backdrop == WindowBackdrop::SolidColor))