• Welcome to Valhalla Legends Archive.
 

Locate a file's icon image

Started by Yegg, May 10, 2006, 10:44 PM

Previous topic - Next topic

Yegg

Would anyone happen to know where the icon files for the diferent types of file types are located on Windows?

MyndFyre

In the PE Resources section.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Grok

Quote from: Yegg on May 10, 2006, 10:44 PM
Would anyone happen to know where the icon files for the diferent types of file types are located on Windows?

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.

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.