Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7195383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:34:08+00:00 2026-05-28T20:34:08+00:00

I have found various articles on getting the system images for a file or

  • 0

I have found various articles on getting the system images for a file or even file extension. I have the belows methods which are working for obtaining small 16×16 and large 32×32 images.

    // DLL Import
    [DllImport("shell32")]
    private static extern IntPtr SHGetFileInfo(
        string pszPath,
        uint dwFileAttributes,
        ref SHFILEINFO psfi,
        uint cbFileInfo,
        uint uFlags);

    // Constants/Enums
    private const int FILE_ATTRIBUTE_NORMAL = 0x80;

    private enum SHGetFileInfoConstants : int
    {
        SHGFI_ICON = 0x100,                // get icon
        SHGFI_DISPLAYNAME = 0x200,         // get display name
        SHGFI_TYPENAME = 0x400,            // get type name
        SHGFI_ATTRIBUTES = 0x800,          // get attributes
        SHGFI_ICONLOCATION = 0x1000,       // get icon location
        SHGFI_EXETYPE = 0x2000,            // return exe type
        SHGFI_SYSICONINDEX = 0x4000,       // get system icon index
        SHGFI_LINKOVERLAY = 0x8000,        // put a link overlay on icon
        SHGFI_SELECTED = 0x10000,          // show icon in selected state
        SHGFI_ATTR_SPECIFIED = 0x20000,    // get only specified attributes
        SHGFI_LARGEICON = 0x0,             // get large icon
        SHGFI_SMALLICON = 0x1,             // get small icon
        SHGFI_OPENICON = 0x2,              // get open icon
        SHGFI_SHELLICONSIZE = 0x4,         // get shell size icon
        SHGFI_PIDL = 0x8,                  // pszPath is a pidl
        SHGFI_USEFILEATTRIBUTES = 0x10,    // use passed dwFileAttribute
        SHGFI_ADDOVERLAYS = 0x000000020,   // apply the appropriate overlays
        SHGFI_OVERLAYINDEX = 0x000000040   // Get the index of the overlay
    }

    public static Icon GetSmallIconForExtension(string extension)
    {
        // Get the small icon and clone it, as we MUST destroy the handle when we are done.
        SHFILEINFO shinfo = new SHFILEINFO();
        IntPtr ptr = SHGetFileInfo(
            extension,
            FILE_ATTRIBUTE_NORMAL,
            ref shinfo, (uint)Marshal.SizeOf(shinfo),
            (int)(SHGetFileInfoConstants.SHGFI_ICON |
            SHGetFileInfoConstants.SHGFI_SMALLICON |
            SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES |
            SHGetFileInfoConstants.SHGFI_TYPENAME));
        Icon icon = Icon.FromHandle(shinfo.hIcon).Clone() as Icon;
        DestroyIcon(shinfo.hIcon);
        return icon;
    }

    public static Icon GetLargeIconForExtension(string extension)
    {
        // Get the small icon and clone it, as we MUST destroy the handle when we are done.
        SHFILEINFO shinfo = new SHFILEINFO();
        IntPtr ptr = SHGetFileInfo(
            extension,
            FILE_ATTRIBUTE_NORMAL,
            ref shinfo, (uint)Marshal.SizeOf(shinfo),
            (int)(
            SHGetFileInfoConstants.SHGFI_ICON |
            SHGetFileInfoConstants.SHGFI_LARGEICON |
            SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES |
            SHGetFileInfoConstants.SHGFI_TYPENAME
            ));
        Icon icon = Icon.FromHandle(shinfo.hIcon).Clone() as Icon;
        DestroyIcon(shinfo.hIcon);
        return icon;
    }

After getting the icon from one of the above methods, I then convert it to a bitmap as follows:

Image image = icon.ToBitmap();

I am getting 32×32 size bitmap images when specifying SHGetFileInfoConstants.SHGFI_LARGEICON above. Yet, in Windows Explorer you get 48×48 sized icons when you choose to view Medium Icons.

I would like the 48×48 sized icons (not 32×32). What do I need to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:34:09+00:00Added an answer on May 28, 2026 at 8:34 pm

    The sizes for shell icons are given in the documentation for SHGetImageList:

    • 16×16 = small
    • 32×32 = large
    • 48×48 = extralarge
    • 256×256 = jumbo

    So it is expected that when you ask for the “large” icons, you get 32×32. If you want the extralarge icon, you need to get them from the SHIL_EXTRALARGE image list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working JNLP application which I need to distribute to various non-technical
I have been playing around with wf4 for a while. I found various articles,
I have done various tests and I have found that the jQuery validate function
I've tried various editors, both desktop applications and web-based RTEs, but have not found
I have found an interesting issue in windows which allows me to cause the
I have found various topics here and elsewhere on creating an intent for sending
I have searched the site and I've found various solutions, most of them suggesting
I have searched for and found various q/a on this error, but have not
I have a scenario that i suspect is very common, i've found various ideas
I have found various code and libraries for editing Exif . But they are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.