PickIconDlg function

[PickIconDlg is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

Displays a dialog box that allows the user to choose an icon from the selection available embedded in a resource such as an executable or DLL file.


int PickIconDlg(
  _In_opt_    HWND  hwnd,
  _Inout_     PWSTR pszIconPath,
              UINT  cchIconPath,
  _Inout_opt_ int   *piIconIndex


hwnd [in, optional]

Type: HWND

The handle of the parent window. This value can be NULL.

pszIconPath [in, out]


A pointer to a string that contains the null-terminated, fully qualified path of the default resource that contains the icons. If the user chooses a different resource in the dialog, this buffer contains the path of that file when the function returns. This buffer should be at least MAX_PATH characters in length, or the returned path may be truncated. You should verify that the path is valid before using it.


Type: UINT

The number of characters in pszIconPath, including the terminating NULL character.

piIconIndex [in, out, optional]

Type: int*

A pointer to an integer that on entry specifies the index of the initial selection and, when this function returns successfully, receives the index of the icon that was selected.

Return value

Type: int

Returns 1 if successful; otherwise, 0.


The following code example shows the use of PickIconDlg to display a dialog that allows the user to choose an icon embedded in the Shell32.dll file.

int index = 1;
int result = 0;
WCHAR path[MAX_PATH] = L"c:\\windows\\system32\\shell32.dll";

result = PickIconDlg(NULL, path, MAX_PATH, &index);

The dialog box displayed as a result of that call is shown here.

Dialog box showing Shell32 icons

The path and index parameters returned in the PickIconDlg shown above now specify a particular icon. You can use this information in any icon manipulation function or method that accepts those values to name an icon. What you do with them depends entirely on the needs of your application. In this continuation of the earlier example, the values are used to retrieve an icon handle through ExtractIcon.

if (result == 1)
    // The hinst parameter is assumed to have been initialized earlier.
    HICON hicon;
    hicon = ExtractIcon(hinst, path, index);


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

End of client support

Windows Vista

End of server support

Windows Server 2003






Shell32.dll (version 6.0 or later)