[ Where can I find the default icons used for folders and applications? ]
I'm trying to load the default HICON that explorer displays for:
- An open folder
- An exe that has no embedded default icon of its own. This can also be seen in 'Add/Remove Programs' or 'Programs and Features' as it's called on Vista.
Do you know where these can be found? I think the folder icon might be in the resources of explorer.exe. But have no idea where the default application icon can be retrieved from.
And additionally, do you have any sample code that could load them into HICONs.
I really need this to work on multiple Windows OSs: 2000, XP, Vista, 2008
Thanks for the help so far. I'm on Vista and have looked through Shell32.dll. I don't see an icon in there that looks the same as the default one displayed by an application in explorer. I could be missing it - there are 278 icons to look through - is it definitely in there, or is there some other location I should look?
Use the SHGetFileInfo API.
SecureZeroMemory(&sfi, sizeof sfi);
&sfi, sizeof sfi,
SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
will get you the icon handle to the folder icon.
To get the 'open' icon (i.e., the icon where the folder is shown as open), also pass SHGFI_OPENICON in the last parameter to SHGetFileInfo().
ignore all answers which tell you to poke around in the registry! Because that won't work reliably, will show the wrong icons if they're customized/skinned and might not work in future windows versions. Also, if you extract the icons from system dlls/exes you could get into legal troubles because they're copyrighted.
Vista added SHGetStockIconInfo and so on NT6+ its the best way. On older platforms, SHGetFileInfo like Stefan says.
If you want to use undocumented stuff, the first 5 or so icons in the system image list includes the default folder and application icon (system image list is NOT shared on NT, but for some reason, all the copies get the first 5 or so icons without asking for them with SHGetFileInfo) These default icons come from shell32.dll by default, but can be changed in the registry (HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons)
I think they are in %windir%\system32\SHELL32.dll
Found some code in the internet, try if that works:
hDll = LoadLibrary ( "SHELL32.dll" );
wincl.hIcon = LoadIcon (hDll , MAKEINTRESOURCE ( 1 ));
wincl.hIconSm = LoadIcon (hDll, MAKEINTRESOURCE ( 2 ));
Edit: Windows has a lot more icons in the "moricons.dll", but I think the file and folder icons should all be in the shell32.dll. Remind, that icons in Vista have different resolutions, up to 256x256, so the icon you are looking at a resolution 32x32 might look different then the full resolution version of the same icon.
In Visual Studio:
- click on File|Open
- select C:\WINDOWS\System32\Shell32.dll
VS will open the file using the resource explorer. You can now look at all the icon & other resources embedded in shell32.dll.
The user's selected icon can be found in the registry at
By looking up the value here, you'll also pick up if they've changed it for whatever reason.
For folders where a desktop.ini file exists, you'd need to read the
If you are in MFC, following code for loading icons should work.
HICON hicon; hicon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
In the above example, AfxGetResourceHandle() is the only thing where MFC is used, otherwise LoadIcon is an API call as far as I remember.
Icons are available in windows\system32\shell32.dll
If you have visual studio installed, then visual studio is also shipped with a set of icons at a path like this "C:\Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary"
It's probably in explorer.exe.
it's much easier, just open the shell32.dll with resource hacker and right-click on "ICONS" and save all icons resource in a directory.
and you'll get all the windows default icons in that directory.