rifter1818 Posted October 23, 2004 Posted October 23, 2004 How do i get the icon for a file (all i need is the filename of the icon so i can load the icon...) Even shortcuts aswell, windows knows which icon to use therefor the information must be stored somewhere, C# is prefered for any examples. Thanks Quote
Wile Posted October 23, 2004 Posted October 23, 2004 The only route i know is through the registry. I'll use text files (.txt) as an example. It takes 2 lookups in the registry: 1) In the registry, HKEY_CLASSES_ROOT\.txt -> (Default) value = txtfile. 2) HKEY_CLASSES_ROOT\txtfile\DefaultIcon -> (Default) value = name of the icon file. Most time the icon is stored in a executable or dll. In that case the name of the executable and the index nr of the dll is given, comma seperated. This trick works for a lot of extensions, I don't know if it works for all extensions though. Also, there might be a way through the shell to get the default icon associated with a program without using the registry which would make it a bit simpler ;). Just never worked with icons before ;). Quote Nothing is as illusive as 'the last bug'.
ALEX_0077 Posted October 25, 2004 Posted October 25, 2004 I remember in vb6, I would use the API 'ExtractAssociatedIcon'. (This would return a Handle to the Icon) Maybe Allapi has a .Net example next to the 'ExtractAssociatedIcon' API listing. Quote Me = 49% Linux, 49% Windows, 2% Hot gas. ...Bite me. My Site: www.RedPierSystems.net -.net, php, AutoCAD VBA, Graphics Design
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.