20

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:

enter image description here

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?

1

3 Answers 3

23

By default, Explorer will use the icon set by the file type, but this can be overriden by placing an IconPath value in the ShellNew key. I figured this out by using Process Monitor to watch for Registry activity from explorer.exe.

It looks like Windows's existing entries use the REG_EXPAND_SZ data type, but REG_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:

ShellNew entries

As you can see, this doesn't affect the file's icon outside of the New list:

the file's icon is different from the New icon

To include that change in your REG file, add this line right under the "NullFile"="" one:

"IconPath"="%ProgramFiles%\\Windows Mail\\wab.exe,10"

You will need to restart Explorer for the change to take effect.

2
  • 1
    I'm surprised that REG_SZ works with environment variables. Possibly Explorer expands it again.
    – Bob
    Jul 9, 2018 at 5:32
  • @Bob Except for character set conversion for the A functions, the value type does not change the behavior of RegQueryValueEx. The .NET Framework will do the expansion for REG_EXPAND_SZ values by default, but the underlying Windows API does not.
    – Ben N
    Jul 9, 2018 at 16:04
3

Can this icon be set manually?

Yes, using File Types Manager from NirSoft:

About File Types Manager

FileTypesMan is an alternative to the 'File Types' tab in the 'Folder Options' of Windows. It displays the list of all file extensions and types registered on your computer. For each file type, the following information is displayed: Type Name, Description, MIME Type, Perceived Type, Flags, Browser Flags, and more. FileTypesMan also allows you to easily edit the properties and flags of each file type, as well as it allows you to add, edit, and remove actions in a file type.

System Requirements

This utility works on any version of Windows from Windows 98 to Windows 10. For using this utility under Windows 98/ME, you must download the non-Unicode version. For using this utility under x64 system, you should download the x64 version.

Source FileTypesMan - Alternative to 'File Types' manager of Windows


Detailed Instructions

The first thing you’ll need to do is download a copy of File Types Manager. It works in pretty much any version of Windows, but do pay attention to whether you need the 32- or 64-bit version. If you’re not sure, here’s how to figure out whether you’re running a 32-bit or 64-bit version of Windows.

When the download finishes, unzip the folder. It’s a portable app, so you won’t need to install it—just double-click “FileTypesMan.exe” to get started.

fte_1

Click the “Default Icon” column header to sort the list by the Default Icon. Note that for our screenshot, we hid several columns to make things easier to see. You may find the “Default Icon” column further to the right. This groups together all file extensions that already have the same icon. This is convenient if you want to change several related file types that use the same icon. If you only intend to change one file type, feel free to sort by the extension or type name instead.

fte_2

To save some scrolling, we’ll use the find function to get to the file type we’re after. Click the “Find” button on the toolbar (or press Ctrl+F). In the “Find” window, type in the extension for the file type you want to change and then click the “Find Next” button repeatedly until the you arrive at the extension you’re after. You can then click “Cancel” to close the “Find” window.

fte_3

Right click extension whose icon you want to change and then select “Edit Selected File Type.”

fte_4

In the “Edit File Type” window, click the “…” button to the right of the Default Icon text field.

fte_5

The “Change Icon” window shows some basic icons, but click the “Browse” button to find your own icon files. File Types Manager allows you to select EXE, DLL, or ICO files.

fte_6

After you’ve browsed for and selected the icon file you want, the available icons will show up in the list. Select the icon you want from the list and then click “OK.” In this example, we’re using icon files that we downloaded from IconArchive, so there’s only one icon shown. If you’re using a EXE or DLL file, you might see many more icons than with an ICO file.

fte_7

If you need to change the icon for more than one file type, you just need to repeat those steps. And when you’re done, you can close File Type Manager and open up a File Explorer window to check out your changes. In our example, we’ve changed the icons for GIF and PNG file types—two types of picture files we use a lot—to make them a bit easier to distinguish. Before, all picture files were using the same icon—the default icon of our image viewer app.

fte_8

Source How to Change the Icon for a Certain File Type in Windows


Disclaimer

I am not affiliated with NirSoft in any way, I am just an end user of their software.

1
  • Note that this changes the icon of the file type system-wide. This is a useful program though.
    – user487867
    Jul 9, 2018 at 8:58
0

For the record: a blank line must be added after the first line ("Windows Registry Editor Version 5.00") of a *.reg file, or it will throw an error when executed. See: https://support.microsoft.com/en-us/help/310516/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg#syntax for syntax details.

BTW, this is not really an answer to the question, but being new here I'm not allowed to comment. But moderators @robinCTS and @bertieb suggest it can also be submitted as an answer, so here I go. Maybe one of these moderators can move it to the comment zone of the question (and at the same time edit out this par.)? Thx!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .