Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2014-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <qt/winshutdownmonitor.h>7#if defined(Q_OS_WIN)9#include <windows.h>11#include <QDebug>13// If we don't want a message to be processed by Qt, return true and set result to14// the value that the window procedure should return. Otherwise return false.15bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, qintptr *pnResult)16{17Q_UNUSED(eventType);19MSG *pMsg = static_cast<MSG *>(pMessage);21switch(pMsg->message)22{23case WM_QUERYENDSESSION:24{25// Initiate a client shutdown after receiving a WM_QUERYENDSESSION and block26// Windows session end until we have finished client shutdown.27m_shutdown_fn();28*pnResult = FALSE;29return true;30}32case WM_ENDSESSION:33{34*pnResult = FALSE;35return true;36}37}39return false;40}42void WinShutdownMonitor::registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId)43{44typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);45PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)(void*)GetProcAddress(GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate");46if (shutdownBRCreate == nullptr) {47qWarning() << "registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed";48return;49}51if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str()))52qInfo() << "registerShutdownBlockReason: Successfully registered: " + strReason;53else54qWarning() << "registerShutdownBlockReason: Failed to register: " + strReason;55}56#endif
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.