16bool WinShutdownMonitor::nativeEventFilter(
const QByteArray &eventType,
17 void *pMessage,
long *pnResult) {
20 MSG *pMsg =
static_cast<MSG *
>(pMessage);
22 switch (pMsg->message) {
23 case WM_QUERYENDSESSION: {
41void WinShutdownMonitor::registerShutdownBlockReason(
const QString &strReason,
42 const HWND &mainWinId) {
43 typedef BOOL(WINAPI * PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
44 PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(
45 GetModuleHandleA(
"User32.dll"),
"ShutdownBlockReasonCreate");
46 if (shutdownBRCreate ==
nullptr) {
47 qWarning() <<
"registerShutdownBlockReason: GetProcAddress for "
48 "ShutdownBlockReasonCreate failed";
52 if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))
53 qInfo() <<
"registerShutdownBlockReason: Successfully registered: " +
56 qWarning() <<
"registerShutdownBlockReason: Failed to register: " +
void StartShutdown()
Request shutdown of the application.