ExtractIconA function (shellapi.h)
Gets a handle to an icon from the specified executable file, DLL, or icon file.
To retrieve an array of handles to large or small icons, use the ExtractIconEx function.
Syntax
HICON ExtractIconA(
[in] HINSTANCE hInst,
[in] LPCSTR pszExeFileName,
UINT nIconIndex
);
Parameters
[in] hInst
Type: HINSTANCE
Handle to the instance of the application that calls the function.
[in] pszExeFileName
Type: LPCTSTR
Pointer to a null-terminated string that specifies the name of an executable file, DLL, or icon file.
nIconIndex
Type: UINT
Specifies the zero-based index of the icon to retrieve. For example, if this value is 0, the function returns a handle to the first icon in the specified file.
If this value is -1, the function returns the total number of icons in the specified file. 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.
If this value is a negative number not equal to –1, the function returns a handle to the icon in the specified file whose resource identifier is equal to the absolute value of nIconIndex. For example, you should use –3 to extract the icon whose resource identifier is 3. To extract the icon whose resource identifier is 1, use the ExtractIconEx function.
Return value
Type: HICON
The return value is a handle to an icon. If the file specified was not an executable file, DLL, or icon file, the return is 1. If no icons were found in the file, the return value is NULL.
Remarks
When it is no longer needed, you must destroy the icon handle returned by ExtractIcon by calling the DestroyIcon function.
Note
The shellapi.h header defines ExtractIcon as an alias which 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 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 XP [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | shellapi.h |
DLL | Shell32.dll |
API set | ext-ms-win-shell-shell32-l1-2-1 (introduced in Windows 10, version 10.0.10240) |