ExtractAssociatedIcon
TOC
Collapse the table of content
Expand the table of content

ExtractAssociatedIcon function

Gets a handle to an icon stored as a resource in a file or an icon stored in a file's associated executable file.

Syntax


HICON ExtractAssociatedIcon(
  _Reserved_ HINSTANCE hInst,
  _Inout_    LPTSTR    lpIconPath,
  _Inout_    LPWORD    lpiIcon
);

Parameters

hInst [in]

Type: HINSTANCE

A handle to the instance of the calling application.

lpIconPath [in, out]

Type: LPTSTR

Pointer to a string that, on entry, specifies the full path and file name of the file that contains the icon. The function extracts the icon handle from that file, or from an executable file associated with that file.

When this function returns, if the icon handle was obtained from an executable file (either an executable file pointed to by lpIconPath or an associated executable file) the function stores the full path and file name of that executable in the buffer pointed to by this parameter.

lpiIcon [in, out]

Type: LPWORD

Pointer to a WORD value that, on entry, specifies the index of the icon whose handle is to be obtained.

When the function returns, if the icon handle was obtained from an executable file (either an executable file pointed to by lpIconPath or an associated executable file), this value points to the icon's index in that file.

Return value

Type: HICON

If the function succeeds, the return value is an icon handle. If the icon is extracted from an associated executable file, the function stores the full path and file name of the executable file in the string pointed to by lpIconPath, and stores the icon's identifier in the WORD pointed to by lpiIcon.

If the function fails, the return value is NULL.

Remarks

When it is no longer needed, the caller is responsible for freeing the icon handle returned by ExtractAssociatedIcon by calling the DestroyIcon function.

The ExtractAssociatedIcon function first looks for the indexed icon in the file specified by lpIconPath. If the function cannot obtain the icon handle from that file, and the file has an associated executable file, it looks in that executable file for an icon. Associations with executable files are based on file name extensions and are stored in the per-user part of the registry.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shellapi.h

DLL

Shell32.dll

Unicode and ANSI names

ExtractAssociatedIconW (Unicode) and ExtractAssociatedIconA (ANSI)

See also

ExtractAssociatedIconEx
ExtractIcon
ExtractIconEx

 

 

Show:
© 2016 Microsoft