Question: I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window.

How can I accomplish that in C++?

**Update.**

I would be more than happy to have a solution for Windows, MacOS, and Ubuntu (though, I'm not sure if MacOS and Ubuntu have such thing as 'system menu').

Answer: 
Once you have another window's top level handle, you may be able to call [GetMenu()](http://msdn.microsoft.com/en-us/library/ms647640(VS.85).aspx) to retrieve the Window's system menu and then modify it, eg:

```
HMENU hMenu = GetMenu(hwndNext);

```
Re: the update - please note that not even Microsoft Windows requires windows to have a sytem menu. GetMenu( ) may return 0. You'll need to intercept window creation as well, because each new top window presumably needs it too.

Also, what you propose is rather intrusive to other applications. How are you going to ensure they don't break when you modify their menus? And how are you going to ensure you suppress the messages? In particular, how will you ensure you intercept them before anyone else sees them? To quote Raymond Chen, imagine what happens if two programs would try that.