From 97755bbd851e9d2caf9811e47e369f861bd4af0d Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 27 Aug 2020 20:20:15 +0200 Subject: [PATCH] fix: resolve RegisterSuspendResumeNotification dynamically (#25162) --- shell/browser/api/electron_api_power_monitor_win.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/browser/api/electron_api_power_monitor_win.cc b/shell/browser/api/electron_api_power_monitor_win.cc index 27d85684cf99..c56a4b39c751 100644 --- a/shell/browser/api/electron_api_power_monitor_win.cc +++ b/shell/browser/api/electron_api_power_monitor_win.cc @@ -8,7 +8,6 @@ #include #include "base/win/windows_types.h" -#include "base/win/windows_version.h" #include "base/win/wrapped_window_proc.h" #include "ui/base/win/shell.h" #include "ui/gfx/win/hwnd_util.h" @@ -44,7 +43,12 @@ void PowerMonitor::InitPlatformSpecificMonitors() { // For Windows 8 and later, a new "connected standy" mode has been added and // we must explicitly register for its notifications. - if (base::win::GetVersion() >= base::win::Version::WIN8) { + auto RegisterSuspendResumeNotification = + reinterpret_cast( + GetProcAddress(GetModuleHandle(L"user32.dll"), + "RegisterSuspendResumeNotification")); + + if (RegisterSuspendResumeNotification) { RegisterSuspendResumeNotification(static_cast(window_), DEVICE_NOTIFY_WINDOW_HANDLE); }