Blocking WM_QUIT

Quick question.

I have an app that use a native DLL through PInvoke, this DLL may call a PostQuitMessage().

How can I avoid it? (as my app should not close)

I tried AddMessageFilter, but it doesn't trigger the WM_QUIT.

Answers


Yup, IMessageFilter cannot work. WM_QUIT makes the GetMessage() function return FALSE. It never gets around to calling the message filter, the message loop immediately exits. Overriding WndProc() or canceling OnFormClosing() won't work either. The only workaround I can think of is Detours to disable PostQuitMessage(). That requires some C/C++ skillz.


PostQuitMessage() will have no effect if you call from a thread that doesn't own any windows.


Need Your Help

How do I display sentences from a website?

python screen-scraping

I decided to make this little project to learn how to use mechanize. For now it goes to urbandictionary, fills in the word 'skid' inside the search form and then press submit and prints out the HTM...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.