Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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
Posted

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 ;).

Nothing is as illusive as 'the last bug'.
Posted

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.

Me = 49% Linux, 49% Windows, 2% Hot gas.

 

...Bite me.

 

My Site: www.RedPierSystems.net

-.net, php, AutoCAD VBA, Graphics Design

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...