Funktionreferenz


_WinAPI_ShellGetStockIconInfo


Retrieves information about system-defined Shell icons

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

Parameter

$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

Rückgabewert

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

Bemerkungen

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.

Verwandte Funktionen

_WinAPI_DestroyIcon

Siehe auch

Suche nach SHGetStockIconInfo in der MSDN Bibliothek.

Beispiel

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

Global Const $STM_SETIMAGE = 0x0172

If Number(_WinAPI_GetVersion()) < 6.0 Then
    MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Fehler', 'Benötigt Windows Vista oder neuer.')
    Exit
EndIf

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

Local $tSHSTOCKICONINFO, $hIcon, $hOld, $Count = 0, $Update = True
While 1
    If $Update Then
        GUICtrlSetData($Label, 'SIID: ' & $Count)
        $tSHSTOCKICONINFO = _WinAPI_ShellGetStockIconInfo($Count, $SHGSI_ICONLOCATION)
        $hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($tSHSTOCKICONINFO, 'Path'), DllStructGetData($tSHSTOCKICONINFO, 'iIcon'), 128, 128)
        $hOld = _SendMessage($Icon, $STM_SETIMAGE, 1, $hIcon)
        If $hOld Then
            _WinAPI_DestroyIcon($hOld)
        EndIf
        $Update = 0
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Prev
            $Count -= 1
            If $Count < 0 Then
                $Count = $SIID_MAX_ICONS - 1
            EndIf
            $Update = 1
        Case $Next
            $Count += 1
            If $Count > $SIID_MAX_ICONS - 1 Then
                $Count = 0
            EndIf
            $Update = 1
    EndSwitch
WEnd