15#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
16bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
void *pMessage, qintptr *pnResult)
18bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
void *pMessage,
long *pnResult)
23 MSG *pMsg =
static_cast<MSG *
>(pMessage);
27 case WM_QUERYENDSESSION:
46void WinShutdownMonitor::registerShutdownBlockReason(
const QString& strReason,
const HWND& mainWinId)
48 typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
49 PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)(
void*)GetProcAddress(GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
50 if (shutdownBRCreate ==
nullptr) {
51 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";
55 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
56 qInfo() <<
"registerShutdownBlockReason: Successfully registered: " + strReason;
58 qWarning() <<
"registerShutdownBlockReason: Failed to register: " + strReason;