I want to customize the menu you get when you right-click on a folder on the windows desktop and windows explorer. As The text displayed by my menu should be dynamic (depending of the folder path), I implement the IContextMenu
interface in a C++ Dll and specify the CLSID
and DLL path in my registery.
It works, when the user right click on a folder, the shell call my IContextMenu::QueryContextMenu
fonction and I can insert my MENUITEMINFOA
struct in the HMENU
. Then the user can see it in the context menu.
My question is how to get the folder path the user has right-click on before inserting my MENUITEMINFOA
struct in the HMENU
So i can adapt what I put in the MENUITEMINFOA.dwTypeData
?
I tried to implement the IShellExtInit
interface as it seems the shell can give information using this interface but when I log the call to my dll I see that the shell never call IShellExtInit::Initialize
.
I guess the shell give the information via an interface I didn't implement but I found no clue on the documentation. However this seems possible to do as, for example, TortoiseSVN do it : the context menu show "SVN Checkout..." on some folder and "SVN Update" / "SVN Commit..." on some others.
I wish you a nice day :)
Problem Solved
The shell do ask for a IShellExtInit
just after asking for a IContextMenu
. I was just confuse by the fact that StringFromIID
and COMView don't know the IID of these interfaces (but thanks to @SimonMourier's tool www.magnumdb.com, I could confirm the IID the shell asked was these interfaces).
The (main) issue was I didn't cast my object to the interface asked (I though it wasn't needed as long as my object expose the right methods). When I static_cast
my object on the IShellExtInit
interface when asked for, the shell do call IShellExtInit::Initialize
.