PrivateExtractIconsW function (winuser.h)

[This function is not intended for general use. It may be altered or unavailable in subsequent versions of Windows.]

Creates an array of handles to icons that are extracted from a specified file.

Syntax

UINT PrivateExtractIconsW(
  [in]            LPCWSTR szFileName,
  [in]            int     nIconIndex,
  [in]            int     cxIcon,
  [in]            int     cyIcon,
  [out, optional] HICON   *phicon,
  [out, optional] UINT    *piconid,
  [in]            UINT    nIcons,
  [in]            UINT    flags
);

Parameters

[in] szFileName

Type: LPCTSTR

The path and name of the file from which the icon(s) are to be extracted.

[in] nIconIndex

Type: int

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.

[in] cxIcon

Type: int

The horizontal icon size wanted. See Remarks.

[in] cyIcon

Type: int

The vertical icon size wanted. See Remarks.

[out, optional] phicon

Type: HICON*

A pointer to the returned array of icon handles.

[out, optional] piconid

Type: UINT*

A pointer to a returned resource identifier for the icon that best fits the current display device. The returned identifier is 0xFFFFFFFF if the identifier is not available for this format. The returned identifier is 0 if the identifier cannot otherwise be obtained.

[in] nIcons

Type: UINT

The number of icons to extract from the file. This parameter is only valid when extracting from .exe and .dll files.

[in] flags

Type: UINT

Specifies flags that control this function. These flags are the LR_* flags used by the LoadImage function.

Return value

Type: UINT

If the phicon parameter is NULL and this function succeeds, then the return value is the number of icons in the file. If the function fails then the return value is 0.

If the phicon parameter is not NULL and the function succeeds, then the return value is the number of icons extracted. Otherwise, the return value is 0xFFFFFFFF if the file is not found.

Remarks

This function extracts from executable (.exe), DLL (.dll), icon (.ico), cursor (.cur), animated cursor (.ani), and bitmap (.bmp) files. Extractions from Windows 3.x 16-bit executables (.exe or .dll) are also supported.

The cxIcon and cyIcon parameters specify the size of the icons to extract. Two sizes can be extracted by putting the first size in the LOWORD of the parameter and the second size in the HIWORD. For example, MAKELONG(24, 48) for both the cxIcon and cyIcon parameters would extract both 24 and 48 size icons.

You must destroy all icons extracted by PrivateExtractIcons by calling the DestroyIcon function.

This function was not included in the SDK headers and libraries until Windows XP Service Pack 1 (SP1) and Windows Server 2003. If you do not have a header file and import library for this function, you can call the function using LoadLibrary and GetProcAddress.

Note

The winuser.h header defines PrivateExtractIcons as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-misc-l1-5-1 (introduced in Windows 10, version 10.0.14393)

See also

Conceptual

DestroyIcon

ExtractIcon

ExtractIconEx

Icons

Reference