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 = (PSHUTDOWNBRCREATE)GetProcAddress(
50 GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
51 if (shutdownBRCreate ==
nullptr) {
52 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for "
53 "ShutdownBlockReasonCreate failed";
57 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
58 qInfo() <<
"registerShutdownBlockReason: Successfully registered: " +
61 qWarning() <<
"registerShutdownBlockReason: Failed to register: " +
void StartShutdown()
Request shutdown of the application.