How deep is the Win32 message queue?

2020-02-05 12:20发布

问题:

How many messages does the queue for a standard window hold? What happens when the queue overflows?

The documentation for GetMessage and relatives doesn't say anything about this, and PeekMessage only gives you a yes/no for certain classes of messages, not a message count.

This page says that the queues are implemented using memory-mapped files, and that there is no message count limit, but that page is about WinCE. Does this apply to desktop Win32 as well?

回答1:

10000 by default, but it can be adjusted via the registry.

If queue overflows, PostMessage fails.

Documentation here:

PostMessage function on MSDN



回答2:

As stated in the MSDN article, if you need to worry about the size of the message queue, you might be better off redesigning your application.