WIN10电源键关机如何不显示立即结束窗口

问题遇到的现象和发生背景

系统运行时,仅运行一个应用程序A,当用户按下电脑的电源键时(已设置为关机且启用了“关闭会阻止或取消关机的应用程序的自动终止功能”),应用程序A通过nativeEventFilter()接收到关机信号:WM_QUERYENDSESSION,弹出应用程序A的提示窗口,询问是否进行关机。如果用户点击关机,则进行关机。然而,按下电源键后,Win10系统出现了立即结束应用程序A的弹窗,目前的处理措施是在立即结束弹窗出现后,给该窗口发关闭消息立即关闭该 弹窗,但是却能够肉眼看见这个过程,体验不好,有什么好的办法可以截获相关的API不进行弹窗。

问题相关代码,请勿粘贴截图

if (eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG")
{
MSG *pMsg = reinterpret_cast<MSG*>(message);

    if (pMsg->message == WM_QUERYENDSESSION)
    {
        std::thread closeWindowThread([this]() {
            while (true) {
                std::wstring name(L"结束程序 - 应用程序A");
                HWND handle = FindWindow(nullptr, name.c_str());
                if (handle) {
                    SendMessage(handle, WM_CLOSE, 0, 0);
                    return;
                }
                std::this_thread::sleep_for(std::chrono::milliseconds(50));
            }
        });
        int res = CMsgBoxView::showMsgBox(EMSGTYPE::MSG_NORMAL_TIP, tr("A is running, really shut down?"));
        if (res == CMsgBoxView::EMSGBUTTON::E_CANCEL_BTN)
        {
            closeWindowThread.detach();

            return true;
        }
        else {
            closeWindowThread.detach();
            
            return false;
        }
    }
    
}
return  QWidget::nativeEvent(eventType, message, result);
运行结果及报错内容

应用程序A的关机阻止界面显示后,用户点击确定,Win10系统出现了“立即结束”应用程序A的弹窗,
目前是在弹窗出现后,立即关闭该 弹窗,但是却能够肉眼看见这个过程

我的解答思路和尝试过的方法

进过分析立即结束窗口是CSRSS.exe产生的。

我想要达到的结果

电源键关机时,不弹出系统的立即结束窗口。

那你直接执行shutdown -h 0,立即关机,不就得了,别管什么弹窗不弹窗的