Fix Windows dark mode detection: OpenKey can fail (#2068)

* Fix Windows dark mode detection: OpenKey can fail

#1497 introduced reading hardcoded Windows Registry key, which assumes key exists. This is not true on Windows 7. Later addition of `try-except` block missed that OpenKey might fail.

This fix allows launching current version of Anki on Windows 7 when installed with Pip with the modified Python 3.9 installation.

* Update CONTRIBUTORS

CI req: Add myself to the contributor list
This commit is contained in:
Zoom 2022-09-15 02:04:19 +00:00 committed by GitHub
parent 35431c5944
commit 3ec7e23d7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -105,6 +105,7 @@ dobefore <1432338032@qq.com>
Bart Louwers <bart.git@emeel.net>
Sam Penny <github.com/sam1penny>
Yutsuten <mateus.etto@gmail.com>
Zoom <zoomrmc+git@gmail.com>
********************

View file

@ -297,11 +297,11 @@ def get_windows_dark_mode() -> bool:
QueryValueEx,
)
key = OpenKey(
HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
)
try:
key = OpenKey(
HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
)
return not QueryValueEx(key, "AppsUseLightTheme")[0]
except Exception as err:
# key reportedly missing or set to wrong type on some systems