# How can I add an icon to my custom context menu item in Windows 7?

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?

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:

The result:

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.

• 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? – Iszi Feb 21 '12 at 13:27
• @Iszi - not sure if there's any real difference. I just happened to find such an example – Siim K Feb 21 '12 at 18:59
• 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. – Iszi Feb 21 '12 at 19:39
• Tested and works in Windows 7. I'll go ahead and post XP as another question. – Iszi Feb 22 '12 at 3:33
• @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 – Siim K May 8 '17 at 21:26

...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.

• what does the number '0' following the path means? – luochen1990 May 8 '17 at 12:48
• @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 – Christian Sirolli Nov 6 '17 at 0:02