Function Reference


_WinAPI_GetIconInfoEx

Retrieves information about the specified icon or cursor

#include <WinAPIRes.au3>
_WinAPI_GetIconInfoEx ( $hIcon )

Parameters

$hIcon Handle to the icon or cursor. To retrieve information about a standard icon or cursor, use $IDC_* constants.

Return Value

Success: The array that contains the following information:
    [0] - A value of 1 specifies an icon; 0 specifies a cursor.
    [1] - The x-coordinate of the cursor's hot spot.
    [2] - The y-coordinate of the cursor's hot spot.
    [3] - A handle to the icon bitmask bitmap.
    [4] - A handle to the icon color bitmap.
    [5] - The icon or cursor resource bits.
    [6] - The fully qualified path of the module.
    [7] - The fully qualified path of the resource.
Failure: Sets the @error flag to non-zero.

Remarks

The _WinAPI_GetIconInfoEx() creates bitmaps [3] and [4].
The calling application must manage these bitmaps and delete them when they are no longer necessary.

This function requires Windows Vista or later.

See Also

Search GetIconInfoEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hInstance = _WinAPI_LoadLibraryEx(@AutoItExe, $LOAD_LIBRARY_AS_DATAFILE)
Local $hIcon = _WinAPI_LoadImage($hInstance, 99, $IMAGE_ICON, 0, 0, $LR_DEFAULTSIZE)
Local $aInfo = _WinAPI_GetIconInfoEx($hIcon)
If IsArray($aInfo) Then
    ConsoleWrite('Handle: ' & $hIcon & @CRLF)
    ConsoleWrite('Path:   ' & $aInfo[6] & @CRLF)
    ConsoleWrite('ID:     ' & $aInfo[5] & @CRLF)
    For $i = 3 To 4
        _WinAPI_DestroyIcon($aInfo[$i])
    Next
EndIf
_WinAPI_FreeLibrary($hInstance)
_WinAPI_DestroyIcon($hIcon)