Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function retrieves icon handles from the specified executable file or dynamic-link library (DLL).

Syntax

HICON ExtractIconEx(
  LPCTSTR 
lpszFile, 
  int 
nIconIndex,
  HICON FAR* 
phiconLarge,
  HICON FAR* 
phiconSmall,
  UINT 
nIcons
);

Parameters

lpszFile

[in] Long pointer to a null-terminated string that specifies the name of an executable file or DLL file from which to extract icons.

nIconIndex

[in] Specifies the zero-based index of the first icon to extract. For example, if this value is zero, the function extracts the first icon in the specified file.

For Windows CE 2.10 and later, the nIconIndexparameter must be zero or –N, where N is a specified resource identifier. The nIconsparameter must be 1.

For Windows CE 1.0 through 2.10, the function returns the total number of icons in the specified file if nIconIndexis –1 and phIconLargeand phiconSmallare both NULL. If the file is an executable file or DLL, the return value is the number of RT_GROUP_ICON resources. If the file is an .ICO file, the return value is 1.

phiconLarge

[in, out] Pointer to an array to receive handles to large icons extracted from the file. If this parameter is NULL, no large icons are extracted from the file.

phiconSmall

[in, out] Pointer to an array to receive handles to small icons extracted from the file. If this parameter is NULL, no small icons are extracted from the file.

nIcons

[in] Specifies the number of icons to extract from the file. For Windows CE 2.10 and later, the nIconsparameter must be 1.

Return Value

For Windows CE 2.10 and later, this function returns the handle to the first icon in the retrieved icon array. If both phiconLargeand phiconSmallare not NULL, the return value defaults to the first large icon.

For Windows CE 1.0 through 2.10, this function returns a UINTdata type. If the nIconIndexparameter is –1, the phiconLargeparameter is NULL, and the phiconSmallparameter is NULL, the return value is the number of icons contained in the specified file. Otherwise, the return value is the number of icons successfully extracted from the file.

Remarks

Your application must destroy all icons extracted by this function by calling the DestroyIconfunction for each icon. Note that destruction of all the icons in the retrieved array also destroys the returned icon.

To retrieve the dimensions of the large and small icons, use the GetSystemMetricsfunction with the SM_CXICON, SM_CYICON, SM_CXSMICON, and SM_CYSMICON flags.

Requirements

Header shellapi.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also