Modifying global system menus

徘徊边缘 提交于 2019-12-18 05:25:07

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1943965/modifying-global-system-menus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!