If you're comfortable enough, you can dig through icoextract to see how it works and then implement that in your code. If not just call the executable.
`icoextract` doesn't provide you with an executable btw