When I use theSendMessage function with HWND_BROADCAST, the application hangs up. There is no response from the application for long time.
This is because when SendMessage is called with HWND_BROADCAST, it first enumerates all the windows available and then calls SendMessage for each of those windows. SendMessage will not return until the window has finished processing the message. If a single window is taking a long time to process the message, the entire call will be delayed.