How many messages in message queue?

I am writing an application with Delphi that responds to
a user defined message (coming from another application
of mine) WM_USER+17.

Is it possible to find out how many messages are in the message
queue, and even more specifically how many WM_USER+17 messages
are waiting?

Advice and help very welcome.

Thanks,

Mike Watson.
--
Mayes uk