Get the true icons of a file
-
How can i get the true icons of a file using c#. When someone enters a whole path (which exist) in a textbox. e.g. If it is "c:\tekst1.txt", how can i get the file icon. Here it is a plain text icon. If you enter the path of a ms-word doc. I will get the ms-word icon. Is there some class availible or need i to read the registry entries in the Classes_root. (when the registry refer to a ico-file this is no problem, but most programs refer to an exe-file. Thanks Jonathan Slenders
-
How can i get the true icons of a file using c#. When someone enters a whole path (which exist) in a textbox. e.g. If it is "c:\tekst1.txt", how can i get the file icon. Here it is a plain text icon. If you enter the path of a ms-word doc. I will get the ms-word icon. Is there some class availible or need i to read the registry entries in the Classes_root. (when the registry refer to a ico-file this is no problem, but most programs refer to an exe-file. Thanks Jonathan Slenders
See if this helps: http://www.kennyandkarin.com/Kenny/CodeCorner/Tools/IconBrowser/[^] Cheers, Simon sig ::
"Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards
"It'll be a cold day in Hell when I do VB.NET...", Chris Maunder -
How can i get the true icons of a file using c#. When someone enters a whole path (which exist) in a textbox. e.g. If it is "c:\tekst1.txt", how can i get the file icon. Here it is a plain text icon. If you enter the path of a ms-word doc. I will get the ms-word icon. Is there some class availible or need i to read the registry entries in the Classes_root. (when the registry refer to a ico-file this is no problem, but most programs refer to an exe-file. Thanks Jonathan Slenders
I've answered this question a few times before. See http://www.codeproject.com/script/comments/forums.asp?msg=585938&forumid=1649&XtraIDs=1649&searchkw=SHGetFileInfo&sd=11%2F15%2F1999&ed=3%2F15%2F2004#xx585938xx[^] for one example. If you are using the full paths, you can drop the UseFileAttributes[^] flag and specify the full path. This will get any overlays necessary and with the right flags get the actual icon for the file. For instance, .htm? files have a default icon associated with them. If they have the right META tags for an Office application that made them, the icon is slightly different.
ShGetFileInfo
can get that icon if you use the right flags. See the documentation for ShGetFileInfo[^] in the Platform SDK for more information.Microsoft MVP, Visual C# My Articles