mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 07:46:17 -07:00
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:
parent
975b44d05f
commit
7276a79cef
5 changed files with 15 additions and 39 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <powrprof.h>
|
||||
#include <Shlobj.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
|
@ -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<PSETSUSPENDSTATE>("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.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue