Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get the true icons of a file

Get the true icons of a file

Scheduled Pinned Locked Moved C#
csharpwindows-adminhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jonathan Slenders
    wrote on last edited by
    #1

    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

    S H 2 Replies Last reply
    0
    • J 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

      S Offline
      S Offline
      SimonS
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • J 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

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups