- How to get the icon path and index associated with a file type?
- Background
- ExtractAssociatedIcon
- SHDefExtractIcon
- Buggy Registry Spelunking
- SHGetFileInfo
- IExtractImage
- IThumbnailProvider
- AssocQueryString
- The question
- Windows 10 icons. Where are they located? In which files and folders?
- How are Windows 10 icons stored?
- Where are Windows 10’s default icons located?
- How to use the icons stored inside a .DLL file
- Do you know any other DLL files with icons from Windows 10?
- How to Change the Icon for a File Type in Windows?
- How to Change the Default Icon for a File Type?
- Method 1: Change file type icon using the Registry Editor
- Registry Branch Not Found?
- Icons From DLL/EXE Files
- Additional note
- Method 2: Change file type icon using Default Programs Editor
- Method 3: Change file type icon using FileTypesMan
- Change the icon for unknown and extensionless files
How to get the icon path and index associated with a file type?
Given a file type (e.g. .txt ) how can i get the:
to the file type’s associated icon path and index, e.g.:
I want to convert .txt into:
- Path: %SystemRoot%\system32\imageres.dll
- Index: -102
With this information i can then extract the icon (e.g. using SHDefExtractIcon ).
Background
Every type of file in Windows is registered in the registry. When an icon is assocated with the file, it is specified as a Path to the file that contains the icon, and the index of the icon resource (or as a resource ID if the index is negative).
Using .txt file as an example, the associated DefaultIcon is:
ExtractAssociatedIcon
Retrieves a handle to an indexed icon found in a file or an icon found in an associated executable file.
The idea is that you pass it the path, and the index, and it will go get the icon for you:
That works only when you already know the path and index of the icon you want.
Fortunately, ExtractAssociatedIcon is also able to tell you the path and index for a icon’s file:
If the function cannot obtain the icon handle from that file, and the file has an associated executable file, it looks in that executable file for an icon.
Correctly calling the function in this case is a bit tricky, as it will modify your supplied buffer (causing buffer overruns if you didn’t pad your buffer to be long enough):
When the function returns:
- iconPath: %SystemRoot%\system32\imageres.dll
- iIcon: -102
Why didn’t i just use the HICON returned by ExtractAssociatedIcon? Because ExtratAssociatedIcon doesn’t allow me to specify the size of the Icon i want. It returns the «Shell large icon» and that’s it.
Also, the only way ExtractAssociatedIcon can perform it’s heroic efforts of looking up by file type is if the file actually exists. If the specified file does not exist (which it doesn’t — since there is no foo.txt ), the function fails.
SHDefExtractIcon
Enter SHDefExtractIcon. It is able to extract any size of icon i want, you just have to pass it the path and index of the icon resource:
The only problem is that i have to get the associated path and index for a file type already. And SHDefExtractIcon, unlike ExtractAssociatedIcon, will not perform the heroic lookup for you.
For that i have to perform the lookup myself; which is my question.
Buggy Registry Spelunking
My first attempt is to read the contract of file associations from the other side. I know how default icons are registered, and i can go in reverse.
convert the .ext to the assocated ProgID :
Lookup the DefaultIcon under the [ProgID]
This is the approach used by the code behind this accepted Stackoverflow answer to the same question:
- convert ext to progID
- lookup progID’s DefaultIcon key
Assuming the ext exists, and the progID exists, and the DefaultIcon exists, and the path exists, and i can parse the path, it’s an incorrect unsupported answer. There are edge cases that the accepted code does not handle 1 .
I’d like the Windows API supported way to perform the mapping from .ext to
SHGetFileInfo
There is a handy function SHGetFileInfo. It’s handy because the filename doesn’t need to actually exist. If you pass it the SHGFI_USEFILEATTRIBUTES flag, It means:
Do not access the disk. Pretend that the file/directory exists, and that its file attributes are what I passed as the dwFileAttributes parameter. Do this regardless of whether it actually exists or not.
The only problem is that i cannot specify the icon size i want. I am limited to the sizes of icons that the shell decides it wants to use.
IExtractImage
- it can return the [path],[index] of an associated icon
- i can specify a desired size
Unfortunately it requires a file to actually exist (it has to be something that exists in the shell namespace). When i have a file-type only i can’t use IExtractImage
IThumbnailProvider
IThumbnailProvider, introduced with Windows Vista, is the modern replacement for IExtractImage:
Windows Vista IThumbnailProivder is new for Vista and replaces IExtractImage. Vista still supports IExtractImage but lacks the ability to return the image type (alpha or not).
IThumbnailProvider also lets me supply the desired icon size. Excellent!
IThumbnailProvider normally requires a file to exist in the shell namespace. But that’s only because the Shell API is the only supported way to get ahold («bind») to the IThumbnailProvider shell interface exposed by a file type.
Fortunately i can perform the same horrible hacks i used above, and crawl the registry manually:
if it doesn’t exist:
In the case of my .avi file:
And now i’m off to the races with a CLSID !
Unfortunately it ends there, as IThumbnailProvider requires a file. More precisely, it requires IInitializeWithStream .
I don’t have a stream. I don’t have a file. I only have the notion of a file type.
AssocQueryString
Perhaps AssocQueryString can help me? I don’t actually know — it’s a beast of a function. And i can’t make head nor tails of it.
The question
Given a file type (e.g. «x.txt»), how can i get the associated icon:
so i may extract the icon of my own desired size (likely using SHDefExtractIcon)?
Windows 10 icons. Where are they located? In which files and folders?
Whether you want to change the default icon of a certain folder or the icon of a shortcut you have created, you might wonder where you could find new icons. While there are lots of websites that offer custom made icon sets, you might, however, prefer to use icons that are already found on your Windows 10 computer or device. In this article, we show you where the icons are stored in Windows 10. If you want to find all the default Windows 10 icon files, read on:
How are Windows 10 icons stored?
Icons are usually stored inside ICO files. However, ICO files have a big disadvantage: they can hold only one icon. Windows 10 has lots of applications, folders, files, and shortcuts, and many of them have their unique icons. If Windows had an ICO file for each icon it uses, that would make for a considerable number of icon files.
To resolve this problem, instead of using ICO files to store icons, Windows uses DLL files. The main advantage of a DLL file is the fact that it can hold multiple icons inside. As a matter of fact, you could compare an icon DLL file with a library of icons. When you want to change the icon of a particular file, folder or shortcut, you can just set its icon location to point to a specific DLL file, and a specific icon from it.
Most icons from Windows 10 are stored inside DLL files. In the next section, we show you where these DLLs with icons are found in Windows 10.
Where are Windows 10’s default icons located?
We tried to organize our list of default Windows 10 icons, both by their DLL files location and by taking into consideration the primary purpose of the icons found inside the DLL files. Next, you can see our list of locations from Windows 10 where you find .DLL files containing icons:
The imageres.dll file contains many icons, used almost everywhere in Windows 10. It has icons for different types of folders, hardware devices, peripherals, actions, and so on.
The shell32.dll file also has lots of icons used in various parts of Windows 10. Together with imageres.dll, shell32.dll hosts one of the largest icon collections. Inside it, you can find icons for internet, devices, networks, peripherals, folders and so on.
Pifmgr.dll contains some old-style icons that were found in older versions of Windows, like Windows 95 and Windows 98. In it, you can find funny icons that depict things such as a window, a trumpet, a ball, a wizard hat, and others. 🙂
Explorer.exe has a few icons used by File Explorer and its older versions. The first icon is the default icon used by File Explorer, but the next ones were used in older Windows versions for things like printers, folders, actions, messenger apps, mail, and others.
Accessibilitycpl.dll has a set of icons that are used mainly for the accessibility features in Windows 10. It has icons with people, mouse cursors, a magnifying glass, a mouse and a keyboard, and so on.
Ddores.dll contains icons for hardware devices and resources, such as speakers, headphones, screens, computers, remotes, and gaming pads, mice and keyboards, cameras, printers and so on.
Moricons.dll is another file that contains old-style icons, used by Microsoft in old Windows versions. Most of the icons here are about MS-DOS programs, but you also have icons for old programming languages such as Turbo Pascal or FoxPro.
Mmcndmgr.dll is yet another file with vintage icons, which we believe were designed mainly for computer management related settings. Among others, it includes icons for networks, folders, authentication, time, computers, and servers.
Mmres.dll has a few icons with various audio resources, like speakers, headphones, microphones, and a webcam.
Netcenter.dll has a few icons for network related settings and features.
Netshell.dll contains icons for all kinds of network connections and associated hardware or technologies.
For instance, inside it, you can find icons for Bluetooth, wireless routers, and network connections.
Networkexplorer.dll another .dll file with a few peripherals such as phone, router, a printer or a fax machine, and some network-related icons.
Pnidui.dll has icons for network related settings (Ethernet or wireless status, network locations, etc.). Most of the icons here are transparent white, so you have to select them to see what they look like.
Sensorscpl.dll has a few icons for different kinds of sensors. While most of them look similar, their details indicate things like temperature, power, wind etc.
Setupapi.dll has icons used for the setup wizards of various hardware devices. It has screens, peripherals, hardware components, connectors and plugs, gaming pads, and others.
Wmploc.dll contains multimedia icons used for media devices, music and video files, folders, CD and DVD discs, and so on.
Wpdshext.dll has icons for some portable devices such as cameras, phones or mp3 players, and a few battery indicators.
Comstui.dll includes various classic icons from older versions of Windows.
It has icons with light bulbs, mail, printers, documents, telephones, fax machines and so on.
Ieframe.dll contains the icons used by Internet Explorer for its shortcuts, buttons and menus.
Dmdskres.dll contains icons only used for disk management.
Dsuiext.dll includes icons for network services. It has icons with servers, people, printers, office buildings, authentication services and so on.
Mstscax.dll stores just a few icons used for remote desktop connections, with computers, notifications, and security certificates.
Wiashext.dll has a few icons for various imaging hardware devices, like scanners, cameras, photo and video cameras, and a few similar icons.
Comres.dll contains a few icons that depict a user, a folder, a pencil, and some actions.
Mstsc.exe holds a few other network related icons but also includes other icons like a speaker, a microphone, and a Windows 8 logo.
26. actioncentercpl.dll, aclui.dll, autoplay.dll, comctl32.dll, xwizards.dll, ncpa.cpl, url.dll (all in %systemroot%\system32)
All these files contain icons; however, many have only one icon inside or just a few, so we decided to mention them all together. They have icons used in Windows 10’s Action Center, some error and info icons, an autoplay icon, some user icons, and websites icons.
How to use the icons stored inside a .DLL file
Icons stored inside .DLL files cannot be copied and saved elsewhere, at least not unless you use a special app that can extract icons from .DLL files. However, you can use any icon stored inside such a file, to set it as the icon used by a folder, a library or a shortcut. If you need guidance on how to change the icons associated with your shortcuts, this tutorial helps: How to change the icon of any shortcut in Windows. Just copy and paste the path we provided for the DLL that interests you, in the field named “Look for icons in this file.”
If you are not satisfied with the icons found in Windows 10, then you might want to look at other places to find icons: 7 sites where you can download free desktop icons for Windows 10.
Do you know any other DLL files with icons from Windows 10?
As you have seen, Windows 10 has lots of icon sets that are built-in. Depending on what kind of icon you need, it is a good chance that you’ll find it inside one of the DLL files that we have listed. Do you know other built-in icon locations from Windows 10? If you do, do not hesitate to share them with us, and we promise to update this article as soon as possible.
How to Change the Icon for a File Type in Windows?
It’s surprising that Windows doesn’t have a built-in option to allow users to set custom icons for file types. If you have a custom file type and the corresponding program doesn’t have a nice-looking icon in its .exe or .dll resource, you can change or customize the default icon for that file type manually.
This article explains how to change the default icon for a file type using different methods in Windows. Instructions apply to all versions of Windows, including Windows 10
How to Change the Default Icon for a File Type?
You can change the default icon for a file type using the built-in Registry Editor. In the second method, let’s see how to change the default icon using Default Programs Editor.
Method 1: Change file type icon using the Registry Editor
Let’s assume you want to change the file type icon for .txt files, and here is how to do that.
- Click Start, type regedit.exe and press ENTER
- Navigate to the following branch:
- In the right-pane, note down the value data for Progid (e.g. txtfile ). This is the user chosen (via Default Programs or Open with dialog) Programmatic Identifier for the file extension.
Registry Branch Not Found?
If the DefaultIcon key does not exist by default, you need to create it manually.
Icons From DLL/EXE Files
If you don’t have a custom .ico file, you may use the icon picker dialog box to choose an icon from a EXE/DLL file. To launch the icon picker dialog, right-click on a folder in your system, click Properties. Click the Customize tab, and click Change Icon… button. Use the icon picker to choose the icon and make a note of the index. The index starts from “0” and you need to proceed vertically when counting (top to bottom.)
Browse to shell32.dll or imageres.dll and note down the icon index, simply cancel the icon picker dialog and close folder properties dialog.
For example, to set the 260 th icon in Shell32.dll, mention the following path, in Step 8:
To make it clear, this procedure doesn’t change the file type associations, only the icon assigned to that file type. If the icons don’t update even if you restart Windows, clear and rebuild the icon cache.
Additional note
As the icon change is made to the ProgId txtfile in the registry, it also affects the other file extensions that use the same ProgId. For instance, in my system, the txtfile ProgID is being used by .log , .scp & .wtx file extensions. Those files will also show up with the new icon.
To know which file extensions are using a ProgID (i.e., txtfile), run this command in the Command Prompt window:
RELATED: See article How to Remove File Type Associations Using the Registry Editor for more information on File extension → ProgID mapping.
It’s possible to change the default icon for a file type without affecting other file types. To do that, you’ll need to create a new file class or ProgID for the file extension, and assign the default icon in the newly created file class.
Method 2: Change file type icon using Default Programs Editor
Don’t want to edit the registry to change file type icons? There are 3rd party tools like Default Programs Editor and FileTypesMan that can change the file type icons and association settings.
Default Programs Editor is a very useful tool which helps you to edit file type associations, add or remove AutoPlay handlers and static context menu entries. We’ve covered Default Programs Editor before. Default Programs Editor – A Useful File Association Editor for Windows
In this method, let us see how you can accomplish the task using the Default Programs Editor.
- Download Default Programs Editor, unzip and run the executable.
- Select File Type Settings
- Click Icon
- Select the file extension for which you want to change the icon, in the next screen.
- This screen shows the current icon for the file type. To change it, click on the Browse button.
- In the icon picker dialog that’s displayed, browse and locate an icon, or point to a custom .ico file if you have one. The built-in imageres.dll and shell32.dll files contain many icons for you to choose from.
- Click the Save Icon button to save the changes to the registry.
As you can see in the screenshot, you also have the option to save the settings to a file. In case you need to apply the changes to several computers, you can output the settings to a .REG file. This can be done by clicking the arrow mark near the Save Icon button, and choosing Save to .reg file. You can deploy or apply the .reg file on other computers without having to run the utility again.
That’s it! The default icon for .txt file type is changed would now refresh or update automatically!
[Before] .txt files showing standard icons [After] .txt files showing custom icons
Method 3: Change file type icon using FileTypesMan
FileTypesMan is an alternative to the Folder Options “File Types” tab (XP-era) in 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. This utility works in all Windows versions including, Windows 10.
Screenshots
%SystemRoot%\system32\imageres.dll,-102 is the Windows-default icon for .txt files. Windows-default icon for .txt files
After setting the default icon to %SystemRoot%\system32\imageres.dll,14 via the icon picker dialog, here is how it shows up: Customized .txt files icon
Change the icon for unknown and extensionless files
File types that are not registered with the system and files that have no extension are assigned a generic icon from shell32.dll,0 by default. The unknown or generic icon for unregistered file types and extensionless files can be customized as per your choice so that you don’t have to see the boring icon anymore.
Windows stores the icon setting for unknown file types and extensionless files in this registry key:
The (default) or the unnamed value points to the following icon resource by default:
Using the Registry Editor (Regedit.exe), you can change the (default) value so that it points to a .ico file that you already have or an icon resource inside a .dll or .exe file by mentioning the file name and resource identifier.
Using the Icon picker (a.k.a. the Change Icon dialog), you can use a relevant icon in shell32.dll, 224 that can be assigned for unregistered and extensionless files. You just need to replace the existing Value data ( %SystemRoot%\System32\shell32.dll,0 ) with %SystemRoot%\System32\shell32.dll,224 using the Registry Editor or using the REG files below.
Logoff and login back to your account.
Here is how it looked before:
We’ve changed that to:
Tip: In case the icons don’t automatically refresh even after a logoff-logon cycle, you can force a shell icons refresh using the ie4uinit.exe method or using Default Programs.
Hope the above guide helped you change file type icons on your Windows 10 computer easily!