diff --git a/src/app/application.cpp b/src/app/application.cpp index f065cb72e..3c122bf86 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -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("User32.dll", "ShutdownBlockReasonCreate"); - // Only available on Vista+ - if (shutdownBRCreate) - shutdownBRCreate((HWND)m_window->effectiveWinId(), tr("Saving torrent progress...").toStdWString().c_str()); + ::ShutdownBlockReasonCreate(reinterpret_cast(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("User32.dll", "ShutdownBlockReasonDestroy"); - // Only available on Vista+ - if (shutdownBRDestroy) - shutdownBRDestroy(reinterpret_cast(m_window->effectiveWinId())); + ::ShutdownBlockReasonDestroy(reinterpret_cast(m_window->effectiveWinId())); #endif // Q_OS_WIN delete m_window; UIThemeManager::freeInstance(); diff --git a/src/app/qtlocalpeer/qtlocalpeer.cpp b/src/app/qtlocalpeer/qtlocalpeer.cpp index a8517a77a..71843de4f 100644 --- a/src/app/qtlocalpeer/qtlocalpeer.cpp +++ b/src/app/qtlocalpeer/qtlocalpeer.cpp @@ -116,14 +116,9 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) + QLatin1Char('-') + QString::number(idNum, 16); #if defined(Q_OS_WIN) - using PPROCESSIDTOSESSIONID = BOOL (WINAPI *)(DWORD, DWORD *); - const auto processIdToSessionId = Utils::Misc::loadWinAPI("kernel32.dll", "ProcessIdToSessionId"); - - if (processIdToSessionId) { - DWORD sessionId = 0; - processIdToSessionId(GetCurrentProcessId(), &sessionId); - socketName += (QLatin1Char('-') + QString::number(sessionId, 16)); - } + DWORD sessionId = 0; + ::ProcessIdToSessionId(GetCurrentProcessId(), &sessionId); + socketName += (QLatin1Char('-') + QString::number(sessionId, 16)); #else socketName += (QLatin1Char('-') + QString::number(::getuid(), 16)); #endif diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 7e246fd54..707d2ef8f 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -4531,23 +4531,15 @@ namespace QString convertIfaceNameToGuid(const QString &name) { // Under Windows XP or on Qt version <= 5.5 'name' will be a GUID already. - QUuid uuid(name); + const QUuid uuid(name); if (!uuid.isNull()) return uuid.toString().toUpper(); // Libtorrent expects the GUID in uppercase - using PCONVERTIFACENAMETOLUID = NETIO_STATUS (WINAPI *)(const WCHAR *, PNET_LUID); - const auto ConvertIfaceNameToLuid = Utils::Misc::loadWinAPI("Iphlpapi.dll", "ConvertInterfaceNameToLuidW"); - if (!ConvertIfaceNameToLuid) return {}; - - using PCONVERTIFACELUIDTOGUID = NETIO_STATUS (WINAPI *)(const NET_LUID *, GUID *); - const auto ConvertIfaceLuidToGuid = Utils::Misc::loadWinAPI("Iphlpapi.dll", "ConvertInterfaceLuidToGuid"); - if (!ConvertIfaceLuidToGuid) return {}; - - NET_LUID luid; - const LONG res = ConvertIfaceNameToLuid(name.toStdWString().c_str(), &luid); + NET_LUID luid {}; + const LONG res = ::ConvertInterfaceNameToLuidW(name.toStdWString().c_str(), &luid); if (res == 0) { GUID guid; - if (ConvertIfaceLuidToGuid(&luid, &guid) == 0) + if (::ConvertInterfaceLuidToGuid(&luid, &guid) == 0) return QUuid(guid).toString().toUpper(); } diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index 1e3a08082..a8e4386bc 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -30,6 +30,7 @@ #ifdef Q_OS_WIN #include +#include #include #else #include @@ -117,16 +118,11 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) if (GetLastError() != ERROR_SUCCESS) return; - using PSETSUSPENDSTATE = BOOLEAN (WINAPI *)(BOOLEAN, BOOLEAN, BOOLEAN); - const auto setSuspendState = Utils::Misc::loadWinAPI("PowrProf.dll", "SetSuspendState"); - if (action == ShutdownDialogAction::Suspend) { - if (setSuspendState) - setSuspendState(false, false, false); + ::SetSuspendState(false, false, false); } else if (action == ShutdownDialogAction::Hibernate) { - if (setSuspendState) - setSuspendState(true, false, false); + ::SetSuspendState(true, false, false); } else { const QString msg = QCoreApplication::translate("misc", "qBittorrent will shutdown the computer now because all downloads are complete."); diff --git a/winconf.pri b/winconf.pri index b69b964a6..b4fbdaef3 100644 --- a/winconf.pri +++ b/winconf.pri @@ -34,7 +34,7 @@ win32-g++* { RC_FILE = qbittorrent_mingw.rc - LIBS += libadvapi32 libshell32 libuser32 libole32 libwsock32 libws2_32 + LIBS += libadvapi32 libiphlpapi libole32 libpowrprof libshell32 libuser32 libwsock32 libws2_32 } else:win32-msvc* { CONFIG -= embed_manifest_exe @@ -42,7 +42,7 @@ else:win32-msvc* { RC_FILE = qbittorrent.rc - LIBS += advapi32.lib shell32.lib crypt32.lib User32.lib ole32.lib + LIBS += advapi32.lib crypt32.lib Iphlpapi.lib ole32.lib PowrProf.lib shell32.lib User32.lib } # See an example build configuration in "conf.pri.windows"