Obtient des informations sur les icônes du Shell définies par le système
#include <WinAPIShellEx.au3>
_WinAPI_ShellGetStockIconInfo ( $iSIID, $iFlags )
$iSIID | Une des constantes $SIID_* qui spécifie quelle icône doit être récupérée. |
$iFlags | Les flags qui spécifient quelles informations sont demandées. Ce paramètre peut être une combinaison des valeurs suivantes: $SHGSI_ICONLOCATION $SHGSI_ICON $SHGSI_SYSICONINDEX $SHGSI_LINKOVERLAY $SHGSI_SELECTED $SHGSI_LARGEICON $SHGSI_SMALLICON $SHGSI_SHELLICONSIZE |
Succès: | Retourne la structure $tagSHSTOCKICONINFO qui contient les informations demandées. |
Échec: | Définit @error <> 0, @extended peut contenir le code d'erreur HRESULT. |
Si cette fonction retourne un handle d'icône dans le membre "hIcon" de la structure $tagSHSTOCKICONINFO, vous devez libérer l'icône avec _WinAPI_DestroyIcon() lorsque vous n'en avez plus besoin.
Cette fonction nécessite Windows Vista ou une version ultérieure.
Consultez SHGetStockIconInfo dans la librairie MSDN.
#include <APIShellExConstants.au3> #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(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Erreur', 'Nécessite Windows Vista ou une version ultérieure.') 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 $idPrev = GUICtrlCreateButton('<', 32, 200, 60, 24) Local $idNext = GUICtrlCreateButton('>', 108, 200, 60, 24) GUISetState(@SW_SHOW) Local $tSHSTOCKICONINFO, $hIcon, $hOld, $iCount = 0, $bUpdate = True Do 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 $iMsg = GUIGetMsg() Switch $iMsg Case $idPrev $iCount -= 1 If $iCount < 0 Then $iCount = $SIID_MAX_ICONS - 1 EndIf $bUpdate = 1 Case $idNext $iCount += 1 If $iCount > $SIID_MAX_ICONS - 1 Then $iCount = 0 EndIf $bUpdate = 1 EndSwitch Until $iMsg = $GUI_EVENT_CLOSE