14

Related: How can I add a program to the context menu of all files?

I've created my custom context menu item, and it seems to work on all file types - even through shortcut links. (Selecting my custom option performs the operation on the shortcut target, not the .lnk file.) Now, I'd like to create an icon to make it stand out. My antivirus program and Notepad++ seem to have been able to do this, so I know it's possible. The only question is, how?

asked Feb 21, 2012 at 5:02
1

2 Answers 2

15

Open regedit.exe and find the key that you created for the custom menu item.

Now create a new String value in it and name it Icon. Double-click it and enter the path to your custom icon file:

c:\folder\icon.ico

Optionally you could use the Windows shell32.dll file like in my example: Registry

The result:

Icon in custom context menu

Just an additional note - looks like this method works on Windows 7 (and probably Vista) but the icon did not appear when I tested on Windows XP.

answered Feb 21, 2012 at 9:23
9
  • Thanks for the answer, and testing on XP. I'll have to give this a shot later today. Also, I've noticed your method seems to differ a bit from the answer to my previous question. (See link in this question.) In the previous answer, the text for the context menu item is stored in the key name. In yours, it's stored in a string value within the key. Is there any practical reason for the difference? Commented Feb 21, 2012 at 13:27
  • @Iszi - not sure if there's any real difference. I just happened to find such an example Commented Feb 21, 2012 at 18:59
  • 1
    It seems you're right about it not working on XP. I can't think of why it wouldn't, since my AV and Notepad++ still have icons. They seem to have their functions covered under HKCR\*\shellex\ContextMenuHandlers though, and I can't begin to decipher on my own how those keys work. Commented Feb 21, 2012 at 19:39
  • Tested and works in Windows 7. I'll go ahead and post XP as another question. Commented Feb 22, 2012 at 3:33
  • 2
    @luochen1990 It is the index number - which icon from the .dll is used. Here is a table for shell32.dll with the icons and the corresponding indexes: help4windows.com/windows_7_shell32_dll.shtml Commented May 8, 2017 at 21:26
7

...And If you want, you can use the default/same icon that your program (exe file) already is using.

Simply use something like below as the content of your Icon string value that @Slim K pointed you to in his answer:

"C:\Path\to\YourProgram.exe",0

Sublime Text 3 doesn't use an icon for its context menu option. So I added an Icon string value with the content you see in screenshot.

1

2

GChuf
1,33715 silver badges21 bronze badges
answered Sep 10, 2016 at 8:33
2
  • what does the number '0' following the path means? Commented May 8, 2017 at 12:48
  • 1
    @luochen1990 as mentioned in the accepted answer by Siim K, it is the index number of the icon in the DLL file. In this case, the number zero is the first icon in the DLL. You can read more about this numbering system here Commented Nov 6, 2017 at 0:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.