Create custom right-click context menu item with C# for all desktop shortcuts (windows explorer)
The problem is easy: I've a lot of desktop shortcuts which points to a lot of file, BUT I also have a lot of shortcuts which points to directories pointed by those shortcuts. I want to remove this redundance by simply adding another rightclick menu options for all shortcuts (.lnk files) that allows you to open explorer.exe to the directory containing the file pointed.
While I discovered how to retrive the target of a shortcut and it's working, I found a suggestion on how adding a menu item to rightclick context menu, but it's not working (I put a key under HKCR*\shellext\ContextMenuHandle开发者_Python百科rs called Test and set the base value to "cmd.exe"
But it doesn't work, obviusly
any suggestion?
Update 1: How to add an icon to that menu item?What size should the icon file have? 16x16 or 32x32?
thanks in advance
Go into HKCR\lnkfile
Create a new key called "shell", and below that create another key called whatever you want the display text to be for your context menu handler, I called mine "COMMAND".
Next, create yet another key below that called specifically "command" and make the (Default) value be "cmd.exe", which will be the path to your custom command. Remember to wrap it in quotes if you're going to be pointing to an exe that has spaces.
So for this example, the final key ends up being:
HKCR\lnkfile\shell\COMMAND\command\
Add the (Default) value mentioned above and your test will be working fine.
Additionally, you can use "%1" to specify the full path to the .lnk file being accessed by the context menu, again remember to wrap it in quotes since you never know if it'll be a file that has spaces in it's full path.
精彩评论