An "ico" file usually contains more than a single icon (icons with different resolution / number of colors)
The following function extract the icons stored from a "ico" file into separate files (each icon into its own file), and can be used for "cur" files as well
[code Foxpro]LOCAL lcFName,lcFContent,lnIcoNo,lni,lcExtrIco,lnBytes,lnOffset
lcFName = GETFILE("ICO;CUR")
IF EMPTY(m.lcFName)
RETURN "No file"
ENDIF
lcFContent = FILETOSTR(m.lcFName)
IF LEFT(m.lcFContent,2) <> CHR(0) + CHR(0)
RETURN "No valid Ico file"
ENDIF
IF !INLIST(SUBSTR(m.lcFContent,3,2) , CHR(1) + CHR(0) , CHR(2) + CHR(0))
RETURN "No valid Ico file"
ENDIF
lnIcoNo = CTOBIN(SUBSTR(m.lcFContent,5,2),'RS')
FOR lni = 1 TO m.lnIcoNo
lcExtrIco = LEFT(m.lcFContent,4) + CHR(1) + CHR(0)
lnBytes = CTOBIN(SUBSTR(m.lcFContent,7 + 8 + 16 * (m.lni-1),4),'RS')
lnOffset = CTOBIN(SUBSTR(m.lcFContent,7 + 12 + 16 * (m.lni-1),4),'RS')
lcExtrIco = m.lcExtrIco + SUBSTR(m.lcFContent,7 + 16 * (m.lni-1),12) + CHR(0x16) + CHR(0) + CHR(0) + CHR(0)
lcExtrIco = m.lcExtrIco + SUBSTR(m.lcFContent,1 + m.lnOffset, m.lnBytes)
STRTOFILE(m.lcExtrIco,FORCEEXT('ico'+TRANSFORM(m.lni)+SYS(2015),JUSTEXT(m.lcFName)))
NEXT
RETURN TRANSFORM(m.lnIcoNo) + " files generated"[/code]
http://en.wikipedia.org/wiki/ICO_%28file_format%29
Vilhelm-Ion Praisach