; Icon Extraction DEMO by SKAN ||| Created: 11-05-2008 ||| Last Modified: 11-05-2008 #SingleInstance, Force SetWorkingDir %A_ScriptDir% SetBatchLines, -1 ATC := A_TickCount hModule := DllCall( "GetModuleHandle", Str,"Shell32.dll" ) CallB := RegisterCallback( "EnumResNameProc" ) DllCall( "EnumResourceNamesA", UInt,hModule, UInt,(RT_GROUP_ICON:=14), UInt,CallB,UInt,0 ) EnumResNameProc( hModule, lpszType, lpszName, lParam ) { Global IconGroups, IGCount IconGroups .= ( ( IconGroups!="" ) ? "|" : "" ) . lpszName IGCount += 1 Return True } Loop, Parse, IconGroups, | { FileN := SubStr( "000" A_Index, -3 ) "-" SubStr( "00000" A_LoopField, -4 ) ".ico" hFile := DllCall( "_lcreat", Str,FileN, UInt,0 ) sBuff := GetResource( hModule, A_LoopField, (RT_GROUP_ICON:=14), nSize, hResData ) Icons := NumGet( sBuff+0, 4, "UShort" ) tSize := nSize+( Icons*2 ), VarSetCapacity( tmpBuff,tSize, 0 ), tBuff := &tmpBuff CopyData( sBuff, tBuff, 6 ), sBuff:=sBuff+06, tBuff:=tBuff+06 Loop %Icons% CopyData( sBuff, tBuff, 14 ), sBuff:=sBuff+14, tBuff:=tBuff+16 DllCall( "FreeResource", UInt,hResData ) DllCall( "_lwrite", UInt,hFile, Str,tmpBuff, UInt,tSize ) EOF := DllCall( "_llseek", UInt,hFile, UInt,-0, UInt,2 ) VarSetCapacity( tmpBuff, 0 ) DataOffset := DllCall( "_llseek", UInt,hFile, UInt,18, UInt,0 ) Loop %Icons% { VarSetCapacity( Data,4,0 ) DllCall( "_lread", UInt,hFile, Str,Data, UInt,2 ), nID := NumGet( Data, 0, "UShort" ) DllCall( "_llseek", UInt,hFile, UInt,-2, UInt,1 ) NumPut( EOF, Data ), DllCall( "_lwrite", UInt,hFile, Str,Data, UInt,4 ) DataOffset := DllCall( "_llseek", UInt,hFile, UInt,0, UInt,1 ) sBuff := GetResource( hModule, nID, (RT_ICON:=3), nSize, hResData ) DllCall( "_llseek", UInt,hFile, UInt,0, UInt,2 ) DllCall( "_lwrite", UInt,hFile, UInt,sBuff, UInt,nSize ) DllCall( "FreeResource", UInt,hResData ) EOF := DllCall( "_llseek", UInt,hFile, UInt,-0, UInt,2 ) DataOffset := DllCall( "_llseek", UInt,hFile, UInt,DataOffset+12, UInt,0 ) } DllCall( "_lclose", UInt,hFile ) } MsgBox,64, % A_TickCount-ATC " ms", %IGCount% Icons extracted to %A_WorkingDir% Return ; // end of Auto-Execute Section // ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CopyData( SPtr, TPtr, nSize ) { Return DllCall( "RtlMoveMemory", UInt,TPtr, UInt,SPtr, UInt,nSize ) } GetResource( hModule, rName, rType, ByRef nSize, ByRef hResData ) { hResource := DllCall( "FindResource", UInt,hModule, UInt,rName, UInt,rType ) nSize := DllCall( "SizeofResource", UInt,hModule, UInt,hResource ) hResData := DllCall( "LoadResource", UInt,hModule, UInt,hResource ) Return DllCall( "LockResource", UInt, hResData ) }