How to discover the method that is called by a Windows Context Menu item?
When you click the right mouse button on your clean desktop it opens a context menu. Each item there is a call to a method. To programmatically call those methods, first I need to know which one I want. IIRC there is a tool that helps with that, but I can't remember it开发者_如何学编程s name.
You cannot call such a method in another process. You could try to inject the WM_COMMAND message that a context menu usually generates with SendMessage. Use Spy++ to find out what that message might be, if it exists.
Use Spy++ to find the handle and use SendMessage / PostMessage. It will be something similar to:
hwnd = FindWindow(...)
hmenu = GetMenu(hwnd)
hsubmenu = GetSubMenu(hmenu, 0)
menuid = GetMenuItem(hsubmenu, 1)
SendMessage(hwnd, WM_COMMAND, menuid, 0)
精彩评论