mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
windows: Fix crash in for Windows versions < 17763
In Windows versions < 17763, `GetProcAddress("#132")` from `uxtheme.dll`
also returns a non-null pointer. However, the function does not match
the expected `extern "system" fn() -> bool` prototype, which causes a
crash when it is called.
This fix ensures compatibility by adding proper checks to prevent such
crashes on older Windows versions.
This commit is contained in:
@@ -133,6 +133,12 @@ fn should_apps_use_dark_mode() -> bool {
|
||||
LazyLock::new(|| unsafe {
|
||||
const UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL: PCSTR = 132 as PCSTR;
|
||||
|
||||
// We won't try to do anything for windows versions < 17763
|
||||
// (Windows 10 October 2018 update)
|
||||
if !*DARK_MODE_SUPPORTED {
|
||||
return None;
|
||||
}
|
||||
|
||||
let module = LoadLibraryA(c"uxtheme.dll".as_ptr().cast());
|
||||
|
||||
if module.is_null() {
|
||||
|
||||
Reference in New Issue
Block a user