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

9,507

Solution 1

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.

Solution 2

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

Share:
9,507

Related videos on Youtube

Iszi
Author by

Iszi

This is a canary message, to be removed in the case of my death. If you're reading this, I haven't died yet. Then again, how would you know? I mean, how could I possibly delete this message after my own demise? You know what? Just go ahead and assume I'm dead. Any posts appearing to be made by me are from an impostor who's stolen my identity post-mortem, and only further prove the fact that I am dead. After all, why would I even think to post a canary message if I was expecting to be alive to remove it anyway? In any case, I'm still not the droid you're looking for.

Updated on September 18, 2022

Comments

  • Iszi
    Iszi almost 2 years

    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?

  • Iszi
    Iszi over 12 years
    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?
  • Siim K
    Siim K over 12 years
    @Iszi - not sure if there's any real difference. I just happened to find such an example
  • Iszi
    Iszi over 12 years
    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
    Iszi over 12 years
    Tested and works in Windows 7. I'll go ahead and post XP as another question.
  • H.v.M.
    H.v.M. over 8 years
    The .ico needs to be 32x32.
  • luochen1990
    luochen1990 about 7 years
    what does the number '15' following the path means?
  • luochen1990
    luochen1990 about 7 years
    what does the number '0' following the path means?
  • Siim K
    Siim K about 7 years
    @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
  • Christian Sirolli
    Christian Sirolli over 6 years
    @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
  • Ryan
    Ryan about 4 years
    I could not get it to work on Windows 10.
  • user3700562
    user3700562 over 2 years
    It's not working under Windows 7 either.