16#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
17bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
18 void *pMessage, qintptr *pnResult) {
20bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
21 void *pMessage,
long *pnResult) {
25 MSG *pMsg =
static_cast<MSG *
>(pMessage);
27 switch (pMsg->message) {
28 case WM_QUERYENDSESSION: {
46void WinShutdownMonitor::registerShutdownBlockReason(
const QString &strReason,
47 const HWND &mainWinId) {
48 typedef BOOL(WINAPI * PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
49 PSHUTDOWNBRCREATE shutdownBRCreate =
50 (PSHUTDOWNBRCREATE)(
void *)GetProcAddress(
51 GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
52 if (shutdownBRCreate ==
nullptr) {
53 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for "
54 "ShutdownBlockReasonCreate failed";
58 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
59 qInfo() <<
"registerShutdownBlockReason: Successfully registered: " +
62 qWarning() <<
"registerShutdownBlockReason: Failed to register: " +
void StartShutdown()
Request shutdown of the application.