# Function Reference

# _WinAPI_ShellGetStockIconInfo

Retrieves information about system-defined Shell icons

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetStockIconInfo ( $iSIID, $iFlags )

## Parameters

$iSIID | One of the $SIID_* constants that specifies which icon should be retrieved. Those constants are defined in APIShellExConstants.au3.
$iFlags | The flags that specify which information is requested. This parameter can be a combination of the following values. $SHGSI_ICONLOCATION $SHGSI_ICON $SHGSI_SYSICONINDEX $SHGSI_LINKOVERLAY $SHGSI_SELECTED $SHGSI_LARGEICON $SHGSI_SMALLICON $SHGSI_SHELLICONSIZE

## Return Value

Success: | $tagSHSTOCKICONINFO structure that contains the requested information.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

## Remarks

If this function returns an icon handle in the "hIcon" member of the $tagSHSTOCKICONINFO structure, you are
responsible for freeing the icon with _WinAPI_DestroyIcon() when you no longer need it.
This function requires Windows Vista or later.

## Related

_WinAPI_DestroyIcon

## See Also

Search SHGetStockIconInfo in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <SendMessage.au3>
    #include <StaticConstants.au3>
    #include <WinAPIIcons.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPISys.au3>

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

    GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 236)
    GUICtrlCreateIcon('', 0, 36, 36, 128, 128)
    Local $h_Icon = GUICtrlGetHandle(-1)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $idLabel = GUICtrlCreateLabel('', 70, 174, 60, 14, $SS_CENTER)
    Local $idBtn_Prev = GUICtrlCreateButton('<', 32, 200, 60, 24)
    Local $idBtn_Next = GUICtrlCreateButton('>', 108, 200, 60, 24)
    GUISetState(@SW_SHOW)

    Local $tSHSTOCKICONINFO, $hIcon, $hOld, $iCount = 0, $bUpdate = True
    While 1
        If $bUpdate Then
            GUICtrlSetData($idLabel, 'SIID: ' & $iCount)
            $tSHSTOCKICONINFO = _WinAPI_ShellGetStockIconInfo($iCount, $SHGSI_ICONLOCATION)
            $hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($tSHSTOCKICONINFO, 'Path'), DllStructGetData($tSHSTOCKICONINFO, 'iIcon'), 128, 128)
            $hOld = _SendMessage($h_Icon, $STM_SETIMAGE, 1, $hIcon)
            If $hOld Then
                _WinAPI_DestroyIcon($hOld)
            EndIf
            $bUpdate = 0
        EndIf
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn_Prev
                $iCount -= 1
                If $iCount < 0 Then
                    $iCount = $SIID_MAX_ICONS - 1
                EndIf
                $bUpdate = 1
            Case $idBtn_Next
                $iCount += 1
                If $iCount > $SIID_MAX_ICONS - 1 Then
                    $iCount = 0
                EndIf
                $bUpdate = 1
        EndSwitch
    WEnd