How can I add an icon to my custom context menu item in Windows 7?
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:
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.
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.
Related videos on Youtube
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, 2022Comments
-
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?
-
Ryan about 4 yearsFor Windows 10, stackoverflow.com/questions/20449316/… and stackoverflow.com/a/27090678/470749 were helpful for me.
-
-
Iszi over 12 yearsThanks 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 over 12 years@Iszi - not sure if there's any real difference. I just happened to find such an example
-
Iszi over 12 yearsIt 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 over 12 yearsTested and works in Windows 7. I'll go ahead and post XP as another question.
-
H.v.M. over 8 yearsThe .ico needs to be 32x32.
-
luochen1990 about 7 yearswhat does the number '15' following the path means?
-
luochen1990 about 7 yearswhat does the number '0' following the path means?
-
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 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 about 4 yearsI could not get it to work on Windows 10.
-
user3700562 over 2 yearsIt's not working under Windows 7 either.