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 / C++ / MFC
  4. How to retrieve application icon of a file type ?

How to retrieve application icon of a file type ?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
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.
  • G Offline
    G Offline
    gumber
    wrote on last edited by
    #1

    Hi there, Kindly tell me how to retrieve the application icon of a registered file type from the file extension without having a specific file name. For example, I need to retrieve the application icon associated with file type having extension ".doc". Regards Gaurav:confused: Gaurav Gumber

    I H 2 Replies Last reply
    0
    • G gumber

      Hi there, Kindly tell me how to retrieve the application icon of a registered file type from the file extension without having a specific file name. For example, I need to retrieve the application icon associated with file type having extension ".doc". Regards Gaurav:confused: Gaurav Gumber

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      SHGetFileInfo ( ....., SHGFI_ICON ); Iain.

      1 Reply Last reply
      0
      • G gumber

        Hi there, Kindly tell me how to retrieve the application icon of a registered file type from the file extension without having a specific file name. For example, I need to retrieve the application icon associated with file type having extension ".doc". Regards Gaurav:confused: Gaurav Gumber

        H Offline
        H Offline
        HPSI
        wrote on last edited by
        #3

        HICON GetFileIconHandle(LPCTSTR lpszFileName, BOOL bSmallIcon)
        {
        UINT uFlags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;

        if (bSmallIcon)
            uFlags |= SHGFI\_SMALLICON;
        else
            uFlags |= SHGFI\_LARGEICON;
        
        SHFILEINFO sfi;
        SHGetFileInfo(lpszFileName, FILE\_ATTRIBUTE\_NORMAL, &sfi, sizeof(SHFILEINFO), uFlags);
        
        return sfi.hIcon;
        

        }

        HPS HwndSpy - GUI developer's aid to visually locate and inspect windows. For the month of August only, use coupon code CP-81239 for 30% off.

        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