I'm not entirely sure how this works. So I can add items to the "new" context menu (that appears when right clicking or pressing the menu button) through the registry editor. For example, if I want to create a new .cpp file entry, I can import a .reg file that looks like this:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.cpp]
@="cpp"
[HKEY_CLASSES_ROOT\.cpp\ShellNew]
"NullFile"=""
[HKEY_CLASSES_ROOT\cpp]
@="C++ File"
So I can set the extension and the description that appears for it using this method. However, I'm not sure how the icon that appears next to my description is decided. This is what I mean:
I'm not sure if Windows chooses this picture automatically based upon whatever program I have set as the default for that extension or if it can be set manually in the registry somehow.
Can this icon be set manually?
Best Answer
By default, Explorer will use the icon set by the file type, but this can be overriden by placing an
IconPath
value in theShellNew
key. I figured this out by using Process Monitor to watch for Registry activity fromexplorer.exe
.It looks like Windows's existing entries use the
REG_EXPAND_SZ
data type, butREG_SZ
works equally well and is much easier to include in a REG file. The format is the full path to the file containing the icon, then a comma, then the number of the icon resource within the file. In this screenshot, I used%ProgramFiles%\Windows Mail\wab.exe,10
:As you can see, this doesn't affect the file's icon outside of the New list:
To include that change in your REG file, add this line right under the
"NullFile"=""
one:You will need to restart Explorer for the change to take effect.