Scott Langham
Scott Langham

Reputation: 60311

Where can I find the default icons used for folders and applications?

I'm trying to load the default HICON that explorer displays for:

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?

Upvotes: 4

Views: 13001

Answers (7)

Anders
Anders

Reputation: 101636

Vista added SHGetStockIconInfo and so on NT6+ its the best way.

Archive of MSDN documentation that shows the available icons

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

Upvotes: 7

Joysen
Joysen

Reputation:

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.

[link]http://www.angusj.com/resourcehacker/[/link]

Upvotes: -1

Stefan
Stefan

Reputation: 43575

Use the SHGetFileInfo API.

SHFILEINFO sfi;
SecureZeroMemory(&sfi, sizeof sfi);

SHGetFileInfo(
    _T("Doesn't matter"),
    FILE_ATTRIBUTE_DIRECTORY,
    &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().

[edit]

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.

Upvotes: 12

Xn0vv3r
Xn0vv3r

Reputation: 18184

I think they are in %windir%\system32\SHELL32.dll

Found some code in the internet, try if that works:

HINSTANCE hDll;
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.

Upvotes: 2

Rowland Shaw
Rowland Shaw

Reputation: 38130

The user's selected icon can be found in the registry at HKEY_CLASSES_ROOT\Folder\DefaultIcon

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 IconFile and IconIndex entries.

Upvotes: 1

Ferruccio
Ferruccio

Reputation: 100658

In Visual Studio:

  1. click on File|Open
  2. 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.

Upvotes: 3

Aamir
Aamir

Reputation: 15556

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"

Upvotes: 0

Related Questions