Icemanind
Icemanind

Reputation: 48686

Modifying global system menus

Is there a way in C# to globally add a menu item to all the system menus on all active windows? Perhaps under the "Maximize" command?

Upvotes: 2

Views: 1666

Answers (2)

Alexander Illarionov
Alexander Illarionov

Reputation: 21

You can do it by writing all the logic in C# in an exe file. You will also have to write some code in C/C++ as a hook, which will send events from the menu items to your exe file. You can find an example here https://github.com/AlexanderPro/SmartSystemMenu

Upvotes: 1

John Knoeller
John Knoeller

Reputation: 34148

This can't be done in managed code. And it would be remarkably difficult even in unmanged code. Basically you would have to inject your code into every process, and then insert items into the local system menus, and then hook the main window proc to intercept the WM_SYSCOMMAND messages so that you could make the menu items do something.

You CAN write code that will add the WS_TOPMOST style to (most) windows (security permitting) just by using FindWindow to get the window handle and then SetWindowLong to change the window style.

But you won't be able to put the UI for this into other process's system menus.

Upvotes: 4

Related Questions