Ich bin mir nicht sicher, ob jemand schon ein Script dieser Art gepostet hat, aber bisher sind mir nicht gerade viele Beispiele für die _WinAPI_ExtractIconEx Funktion unter die Augen gekommen.
Hier ist ein Beispiel wie man besagte Funktion verwendet um Icons aus einer Datei zu extrahieren und wie man dann mit den erhaltenen handles weiter verfahren kann (z.B. GDIPlus).
Spoiler anzeigen
#include <WinAPI.au3>
#include <GDIPlus.au3>
; -Author: name22 (http://www.autoit.de)
[/autoit] [autoit][/autoit] [autoit]$iStart = 3 ;0-basierter Index des ersten Icons
$iIcons = 5 ;Anzahl der zu extrahierenden Icons
$t_ahIcons = DllStructCreate("HWND[" & $iIcons & "]") ;HWND Array um die Icons zu erhalten
$p_ahIcons = DllStructGetPtr($t_ahIcons)
_WinAPI_ExtractIconEx(@SystemDir & "\shell32.dll", $iStart, 0, $p_ahIcons, $iIcons) ;Hier wird der pSmall Parameter verwendet um kleine Icons zu extrahieren
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To $iIcons
$hBitmap = _GDIPlus_BitmapCreateFromHICON(DllStructGetData($t_ahIcons, 1, $i)) ;Erzeugt aus dem HICON eine GDI+ Bitmap
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & StringFormat("\Icon%02d.bmp", $i)) ;Speichert die Bitmap
_GDIPlus_BitmapDispose($hBitmap) ;Bitmap löschen
_WinAPI_DestroyIcon(DllStructGetData($t_ahIcons, 1, $i)) ;Icon löschen
Next
_GDIPlus_Shutdown()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_BitmapCreateFromHICON
; Description ...: Creates a Bitmap object based on an icon
; Syntax.........: _GDIPlus_BitmapCreateFromHICON($hIcon)
; Parameters ....: $hIcon - Handle to an icon
; Return values .: Success - Returns a handle to a new Bitmap object
; Failure - 0 and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
; Related .......: _GDIPlus_ImageDispose, _WinAPI_LoadImage, _WinAPI_LoadIcon
; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromHICON
; Example .......; Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapCreateFromHICON($hIcon)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromHICON", "hwnd", $hIcon, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
$GDIP_STATUS = $aResult[0]
Return $aResult[2]
EndFunc ;==>_GDIPlus_BitmapCreateFromHICON
Im Beispiel werden 5 Icons ab dem 3ten Index aus der shell32.dll extrahiert. Ich hoffe es kann jemand gebrauchen.
Bei Fragen bzw. Rückmeldungen meldet euch einfach ;).