views:

293

answers:

2

I'm trying to determine some of the details of how HWND_BROADCAST works. Unfortunately, MSDN doesn't have a specific page for this value; it's only mentioned in passing in several other articles, such as the ones for SendMessage and PostMessage.

What I specifically want to know is whether messages sent to HWND_BROADCAST are received by windows associated with other desktops in the same window station. The docs say the message will go to "all top-level windows in the system", but clearly that can't be strictly true. For instance, I'm sure they wouldn't go to windows in other logon sessions (e.g. on a terminal server). My guess is that they are at least limited to the window station of the calling process, but I don't know if they are also limited to the desktop of the calling thread (each thread is associated with a single desktop).

Worst case I can go write some code to test this empirically, but does anybody happen to know the answer already?

+1  A: 

You are correct. Messages sent in this manner will only go to the top-level windows of the currently logged in windows session/desktop. They will not go to any other desktop.

Robert Harvey
I haven't tested this, but I'll take your word for it. Thanks!
Charlie
A: 

Vista will block the message to be delivered to top-level windows if it comes from a lower privileged process, you should care of it.

Yigang Wu