Valhalla Legends Forums Archive | General Programming | Locate a file's icon image

AuthorMessageTime
Yegg
Would anyone happen to know where the icon files for the diferent types of file types are located on Windows?
May 11, 2006, 3:44 AM
Myndfyr
In the PE Resources section.
May 11, 2006, 5:17 AM
Grok
[quote author=Yegg link=topic=14963.msg152301#msg152301 date=1147319054]
Would anyone happen to know where the icon files for the diferent types of file types are located on Windows?
[/quote]

I think you are asking where the icons are stored for associated file types, such as the notepad.exe icon for Text(*.txt) files would be found.  To answer that question you need to understand something about resources.  Resources are stored in binary files and are indexed.  You also need to understand how associated file types are stored in the Windows Registry.  If you look at HKEY_CLASSES_ROOT, you will see hundreds of entries like .acf, .bat, .cmd, .exe, .pdf, .txt, and so on.  Every file type that windows recognizes has an entry.

Under each entry, such as HKEY_CLASSES_ROOT/.txt there is a way to resolve the path to the binary storing the resource icon.  To resolve the .txt icon on my system, I first determine the default value, which is txtfile.  Finding now the HKEY_CLASSES_ROOT/txtfile entry, we see a DefaultIcon key, the value of which is: %SystemRoot%\system32\shell32.dll,-152
This tells you that the icon is contained in shell32.dll, at the index -152.  Sure enough if you use a resource viewer, you'll find the text file icon that Explorer.exe uses in that DLL resource table.

Hope this helps.
May 15, 2006, 10:29 PM
Yegg
Thank you Grok. However, I should have went into more detail on what I wanted, it was late at night when I made my original post so I was too tired to make a real post. What I've lately been looking for is a function from the Windows API that would allow me to retrieve a handle of an icon from any given file. I believe that SHGetFileInfo is the correct function however I have been having a little trouble using it correctly. When I have some free time I will make another attempt, if I succeed I'll notify you.
May 15, 2006, 10:38 PM

Search