ladiko, i extracted some code from SKAN's
IconEx to create an icon extraction function that will work with named resources as well. I don't exactly know how the extraction part works, but it works

It doesn't use ResHacker and it seems it performs faster.
Code:
IconExtract(Res, Nb = 0, Out = "") ;Resource file, resource number [0..N], Output file
{
Global _IconGroups_, _IconGroupsCount_
Static CallB
If !CallB
CallB := RegisterCallback( "EnumResNameProc" )
Nb:=Nb+1
If (Out = "")
Out := A_WorkingDir "\Icon_1.ico"
Loop, %Res%
{
If (A_LoopFileExt = "ICO")
{
FileCopy, %Res%, %Out%, 1
If !ErrorLevel
Return 1
Else
Return
}
If A_LoopFileExt Not in EXE,DLL,CPL,SCR
Return
hModule := DllCall( "LoadLibraryEx", Str,A_LoopFileLongPath, UInt,0, UInt,0x2 )
IfEqual,hModule,0,Return
_IconGroupsCount_:=0, _IconGroups_ := ""
DllCall("EnumResourceNamesA", UInt,hModule, UInt,14, UInt,CallB, UInt,0 )
DllCall( "FreeLibrary", UInt,hModule )
IfEqual,_IconGroupsCount_,0, Continue
SplitPath, Res,, Res
hModule := DllCall( "LoadLibraryEx", Str,Res "\" DllCall( "CharUpperA", Str,A_LoopFileName, Str ), UInt,0, UInt,0x2 )
}
Loop, Parse, _IconGroups_, |
{
If (A_Index > Nb)
Break
If (A_Index != Nb)
Continue
IconGroup := A_LoopField
hFile := DllCall( "_lcreat", Str,Out, UInt,0 )
sBuff := GetResource( hModule, IconGroup, (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 )
}
DllCall( "FreeLibrary", UInt,hModule )
If IconGroup
Return 1
}
EnumResNameProc( hModule, lpszType, lpszName, lParam )
{
Global _IconGroups_, _IconGroupsCount_
_IconGroups_ .= ( ( _IconGroups_!="" ) ? "|" : "" ) . lpszName , _IconGroupsCount_:=_IconGroupsCount_+1
Return True
}
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 )
}
CopyData( SPtr, TPtr, nSize )
{
Return DllCall( "RtlMoveMemory", UInt,TPtr, UInt,SPtr, UInt,nSize )
}
EDIT: I noticed it didn't work anymore for named icons on Win7 x64...