Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The system uses icons throughout the user interface to represent objects such as files, folders, shortcuts, applications, and documents. The icon functions enable applications to create, load, display, copy, and destroy icons. For information on specifying icons for file types, see How to Assign a Custom Icon to a File Type.
This overview provides information on the following topics:
- Icon Types
- Icon Sizes
- Icon Creation
- The Window Class Icon
- Icon Display
- Icon Destruction
- Icon Duplication
Icon Types
The operating system provides a set of standard icons that are available for any application to use at any time. The software development kit (SDK) header files contain identifiers for the system icons - the identifiers begin with the IDI_ prefix.
| Value | Meaning |
|---|---|
| IDI_APPLICATION MAKEINTRESOURCE(32512) |
Default application icon |
| IDI_ERROR MAKEINTRESOURCE(32513) |
Error icon |
| IDI_QUESTION MAKEINTRESOURCE(32514) |
Question mark icon |
| IDI_WARNING MAKEINTRESOURCE(32515) |
Warning icon |
| IDI_INFORMATION MAKEINTRESOURCE(32516) |
Information icon |
| IDI_WINLOGO MAKEINTRESOURCE(32517) |
Windows logo icon |
| IDI_SHIELD MAKEINTRESOURCE(32518) |
Security shield icon |
See Guidelines for information on recommended usage of standard icons.
Also, starting with Windows Vista, an additional set of standard system shell icons is available through the SHGetStockIconInfo method.
Custom icons are designed for use in a particular application and can be any design. User can load custom icons from files or create them at run-time. Following are several custom icons.

Icon Sizes
See Icon scaling for recommendations on preferred icon sizes for your application.
System icon sizes
System icon sizes are reported by GetSystemMetrics and scale with the display DPI.
| Size | Metric | 96 DPI | 150% (144 DPI) | 200% (192 DPI) | Description |
|---|---|---|---|---|---|
| System small | SM_CXSMICON / SM_CYSMICON | 16x16 | 24x24 | 32x32 | Menus, notification area, Explorer list view |
| System large | SM_CXICON / SM_CYICON | 32x32 | 48x48 | 64x64 | ICON_BIG (WM_SETICON / WM_GETICON), Alt+Tab (legacy/fallback) |
The CreateIconFromResource, DrawIcon, ExtractAssociatedIcon, ExtractIcon, and LoadIcon functions all use the system large icon size. The ExtractIconEx function can retrieve large icons, small icons, or both: the handles returned in phiconLarge use the system large icon size, and those returned in phiconSmall use the system small icon size. The CreateIcon, CreateIconFromResourceEx, CreateIconIndirect, and LoadImage functions can work with icons at any size.
To retrieve system icon sizes, call GetSystemMetrics with SM_CXSMICON / SM_CYSMICON for the small size, or SM_CXICON / SM_CYICON for the large size. In per-monitor DPI-aware applications, use GetSystemMetricsForDpi with the DPI of the target monitor instead, so the returned size reflects the correct display. For more information, see High DPI Desktop Application Development on Windows.
Shell icon sizes
The shell uses a separate set of sizes for Explorer views and the system image lists, accessible via SHGetImageList. Call SHGetImageList with the appropriate SHIL_* constant, then call ImageList_GetIconSize on the returned image list.
| SHIL constant | Source | 96 DPI | 150% (144 DPI) | 200% (192 DPI) | Description |
|---|---|---|---|---|---|
| SHIL_SMALL (1) | SM_CXSMICON | 16x16 | 24x24 | 32x32 | Explorer list/details view, common dialogs, window title bar icon |
| SHIL_SYSSMALL (3) | SM_CXSMSIZE | 16x16 | 24x24 | 32x32 | Shell toolbars, status bars; tracks caption button size; equals SHIL_SMALL at default settings |
| SHIL_LARGE (0) | SM_CXICON | 32x32 | 48x48 | 64x64 | Explorer medium icons view, dialogs |
| SHIL_EXTRALARGE (2) | 48 logical px | 48x48 | 72x72 | 96x96 | Explorer large icons view, desktop |
| SHIL_JUMBO (4) | fixed 256 px | 256x256 | 256x256 | 256x256 | Explorer extra large icons view (Vista+); always 256 physical pixels |
Icon Creation
An icon resource (.ico file or RT_ICON / RT_GROUP_ICON in a PE file) stores multiple images - typically at standard sizes 16, 32, 48, and 256 pixels, optionally at different color depths including 32bpp ARGB for per-pixel alpha transparency. Each image is optimized for its size; providing all standard sizes avoids the quality loss that results from scaling a single image up or down.
To load an icon from a resource, call LoadIcon or LoadImage. The system automatically selects the best-matching image for the requested size and display color depth using the same algorithm as LookupIconIdFromDirectoryEx. To load directly from an .ico file, pass LR_LOADFROMFILE to LoadImage. To load at a non-standard size with high-quality scaling, use LoadIconWithScaleDown - it selects the nearest larger standard image (16, 32, 48, or 256) and scales it down to the requested size.
An application can also create a custom icon at run-time by using the CreateIconIndirect function, which creates an icon based on the contents of an ICONINFO structure. Note that for icons the hotspot fields in ICONINFO are ignored by the system - the hotspot is always the center of the image. The CreateIconFromResourceEx function creates an icon from binary resource data from other executable files or DLLs; use LookupIconIdFromDirectoryEx first to identify the most appropriate image for the current display size and color depth. For examples, see Creating an Icon.
Applications should implement custom icons as resources and use LoadIcon or LoadImage rather than create icons at run-time. Using icon resources avoids device dependence, simplifies localization, and enables applications to share icon shapes.
The Window Class Icon
When you register a window class using the RegisterClassEx function, set the hIcon field of WNDCLASSEX to the large icon (SM_CXICON x SM_CYICON) and hIconSm to the small icon (SM_CXSMICON x SM_CYSMICON). Every window of that class uses these icons by default. For more information, see Class Icons.
To set or update a specific window's icon at run time, send WM_SETICON with ICON_BIG or ICON_SMALL. To retrieve the current icon handle, send WM_GETICON with the same wParam value. To replace the class icon for all windows of a class, use SetClassLongPtr with GCLP_HICON or GCLP_HICONSM.
Icon Display
You can retrieve the image and size of an icon by using the GetIconInfo function - see Getting the Icon size for an example. You can draw the icon by using the DrawIconEx function.
To display an icon in a static control, send STM_SETIMAGE with IMAGE_ICON and the icon handle:
HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
SendMessage(hStatic, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
Icon Destruction
When an application no longer needs an icon, destroy it by calling DestroyIcon. The only exceptions are shared handles, which must not be destroyed:
- LoadIcon - always uses LR_SHARED internally regardless of the instance parameter; use LoadImage without LR_SHARED if you need an owned handle
- LoadImage with LR_SHARED
- CreateIconFromResource - always returns a shared handle
- CreateIconFromResourceEx when called with LR_SHARED
- CopyImage with LR_COPYRETURNORG when the size already matches - returns the original handle, which may be shared
Icon Duplication
The CopyIcon function creates a new independent icon object with the same image as the original. This enables an application or DLL to obtain an icon that outlives the module it was loaded from - if the original module is freed, the copy remains valid. The copy is owned by the caller.
The CopyImage function creates a new icon based on an existing icon handle, optionally at a different size - useful when you already hold a handle and need a resized copy without reloading the original resource.
For information about adding, removing, or replacing icon resources in executable (.exe) files, see Resources.
Default application icon
Error icon
Question mark icon
Warning icon
Information icon
Windows logo icon
Security shield icon