#include <array.au3>
;######################## Func _Pics_GetIcons($filename,$showwin=1) ####################################################
;Syntax:			_Pics_GetIcons($filename,$showwin=1)
;Description:		Returns the name of an icons in a .dll or .exe file. Optional it can show the icon while searching in
;					the file (slower because there is a rytm)
;Parameters:		$filename		the file to search In
;					$showwin=0		[optional] it shows or hides the window
;					$sleep=25		[optional] the rythm to load the next icon
;					$max=500		[optional] how many icon names it have to search
;					$startat=0		[optional] where to start to search
;Author:			Grimbizo
;Remarks:			It is not very fast... recommented is to set $showwin=0 but this may take several secconds.
;Date:				13.January 2012
;Example:
					$icons=_Pics_GetIcons("shell32.dll",1,100,1000,999)
					_ArrayDisplay($icons)
;######################## EndFunc ######################################################################################
Func _Pics_GetIcons($filename,$showwin=0,$sleep=25,$max=500,$startat=0)
	Local $icons[1]
	$picgui=GUICreate("",132,172,-1,-1,0x80000000+0x00800000)
	If $showwin Then GUISetState(@sw_show)
	$label=GUICtrlCreateLabel("",2,130,64,20)
	$label2=GUICtrlCreateLabel("",66,130,64,20)
	$process=GUICtrlCreateProgress(2,150,128,20)
	$actualicon=$startat
	$workingicons=0
	$icons[0]=0
	While 1
		$icon=GUICtrlCreateIcon($filename,$actualicon,2,2,128,128)
		If Not @error Then 
			_ArrayAdd($icons,$actualicon)
			$workingicons+=1
		EndIf
		$actualicon+=1
		GUICtrlSetData($label,$actualicon&"/"&$max)
		GUICtrlSetData($label2,$actualicon*(100/$max)&"%")
		GUICtrlSetData($process,$actualicon*(100/$max))
		If $showwin Then Sleep($sleep)
		GUICtrlDelete($icon)
		If $actualicon=$max Then ExitLoop
	WEnd
	If $showwin Then GUIDelete($picgui)	
	$icons[0]=$workingicons-1
	Return $icons
	If $icons[0]=0 Then SetError(1)
EndFunc