Call Windows API directly

We already bumped the OS requirement to Windows 7 and those functions
can be called directly without the need to load them first.
This commit is contained in:
Chocobo1 2019-09-28 15:46:26 +08:00
parent 975b44d05f
commit 7276a79cef
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
5 changed files with 15 additions and 39 deletions

View file

@ -685,11 +685,8 @@ void Application::cleanup()
m_window->hide();
#ifdef Q_OS_WIN
typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
const auto shutdownBRCreate = Utils::Misc::loadWinAPI<PSHUTDOWNBRCREATE>("User32.dll", "ShutdownBlockReasonCreate");
// Only available on Vista+
if (shutdownBRCreate)
shutdownBRCreate((HWND)m_window->effectiveWinId(), tr("Saving torrent progress...").toStdWString().c_str());
::ShutdownBlockReasonCreate(reinterpret_cast<HWND>(m_window->effectiveWinId())
, tr("Saving torrent progress...").toStdWString().c_str());
#endif // Q_OS_WIN
// Do manual cleanup in MainWindow to force widgets
@ -728,11 +725,7 @@ void Application::cleanup()
#ifndef DISABLE_GUI
if (m_window) {
#ifdef Q_OS_WIN
using PSHUTDOWNBRDESTROY = BOOL (WINAPI *)(HWND);
const auto shutdownBRDestroy = Utils::Misc::loadWinAPI<PSHUTDOWNBRDESTROY>("User32.dll", "ShutdownBlockReasonDestroy");
// Only available on Vista+
if (shutdownBRDestroy)
shutdownBRDestroy(reinterpret_cast<HWND>(m_window->effectiveWinId()));
::ShutdownBlockReasonDestroy(reinterpret_cast<HWND>(m_window->effectiveWinId()));
#endif // Q_OS_WIN
delete m_window;
UIThemeManager::freeInstance();