Extracts the icon with the specified dimension from the specified file
#include <WinAPIShellEx.au3>
_WinAPI_ShellExtractIcon ( $sIcon, $iIndex, $iWidth, $iHeight )
$sIcon | Path and name of the file from which the icon are to be extracted. |
$iIndex | The 0-based index of the icon to extract. If this value is a negative number, the function extracts the icon whose resource identifier is equal to the absolute value of $iIndex. |
$iWidth | Horizontal icon size wanted. |
$iHeight | Vertical icon size wanted. |
Success: | the handle to the extracted icon. |
Failure: | 0. |
If the icon with the specified dimension is not found in the file, it will choose the nearest appropriate icon
and change to the specified dimension.
When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.
Search SHExtractIcons in MSDN Library.
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIIcons.au3>
#include <WinAPIShellEx.au3>
Local $iIndex = 0, $iTotal = _WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', -1, 0, 0, 0)
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 160)
Local $idButton = GUICtrlCreateButton('Next', 50, 130, 70, 23)
Local $idIcon = GUICtrlCreateIcon(@SystemDir & '\shell32.dll', 0, 69, 54, 32, 32)
Local $hIcon = GUICtrlGetHandle(-1)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton
$iIndex += 1
If $iIndex > $iTotal - 1 Then
$iIndex = 0
EndIf
_WinAPI_DestroyIcon(_SendMessage($hIcon, $STM_SETIMAGE, 1, _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', $iIndex, 32, 32)))
EndSwitch
WEnd