Skip to content

Commit

Permalink
fix: resolve RegisterSuspendResumeNotification dynamically (#25168)
Browse files Browse the repository at this point in the history
Co-authored-by: Milan Burda <milan.burda@gmail.com>
  • Loading branch information
trop[bot] and miniak committed Aug 28, 2020
1 parent d6bea2a commit 63720fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shell/browser/api/electron_api_power_monitor_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <wtsapi32.h>

#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"
Expand Down Expand Up @@ -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<decltype(&::RegisterSuspendResumeNotification)>(
GetProcAddress(GetModuleHandle(L"user32.dll"),
"RegisterSuspendResumeNotification"));

if (RegisterSuspendResumeNotification) {
RegisterSuspendResumeNotification(static_cast<HANDLE>(window_),
DEVICE_NOTIFY_WINDOW_HANDLE);
}
Expand Down

0 comments on commit 63720fd

Please sign in to comment.