简体   繁体   中英

Sharing message queues among threads (in Windows)

有没有什么方法可以在多个线程之间共享消息队列,或者以其他方式读取不同线程的消息队列,而无需使用钩子?

GetMessage and PeekMessage only read messages for the current thread, you can't use them to read messages sent to the input queue owned by another thread.

Try joining the thread input queues using AttachThreadInput , that might work.

Messages in a message queue can be differentiated on the basis of the window they're for, but I don't think messages can be differentiated on the basis of an inteded thread - the fields just aren't there in the MSG structure - so I don't think you can share a queue over multiple threads.

That leaves you with a non-hook monitoring solution.

I'm pretty sure you could peek another threads queue, but the problem is you're basically polling; so you'll miss messages.

Do you have any influence over the threads you wish to read? if so, you can get them to rebroadcast their messages to you.

Apart from that, I can't see a way to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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