简体   繁体   English

阻止WM_QUIT

[英]Blocking WM_QUIT

Quick question. 快速提问。

I have an app that use a native DLL through PInvoke, this DLL may call a PostQuitMessage(). 我有一个通过PInvoke使用本机DLL的应用程序,此DLL可能调用PostQuitMessage()。

How can I avoid it? 我该如何避免呢? (as my app should not close) (因为我的应用程序不应关闭)

I tried AddMessageFilter, but it doesn't trigger the WM_QUIT. 我尝试了AddMessageFilter,但它不会触发WM_QUIT。

Yup, IMessageFilter cannot work. 是的,IMessageFilter无法正常工作。 WM_QUIT makes the GetMessage() function return FALSE. WM_QUIT使GetMessage()函数返回FALSE。 It never gets around to calling the message filter, the message loop immediately exits. 它永远不会调用消息过滤器,消息循环立即退出。 Overriding WndProc() or canceling OnFormClosing() won't work either. 覆盖WndProc()或取消OnFormClosing()也不起作用。 The only workaround I can think of is Detours to disable PostQuitMessage(). 我能想到的唯一解决方法是Detours禁用PostQuitMessage()。 That requires some C/C++ skillz. 这需要一些C / C ++技能。

如果从不拥有任何窗口的线程进行调用,则PostQuitMessage()将无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM