Windows API - ExtractIcon, render icon to image?

Blitz3D Forums/Blitz3D Programming/Windows API - ExtractIcon, render icon to image?

Mr Snidesmin(Posted 2009) [#1]
I would like to use the windows API to extract the icon info for a file or file type and then render the result to a blitz (directx) imagebuffer so I can use it in textures, images within the program etc.

Anyone have any idea how to do this?

I've been able to use the API to get the icon handle and then tried using drawicon and passing in the imagebuffer instead of a window handle. Not working at all as I kind of suspected. Any ideas???

----
API functions used:

.lib "shell32.dll"
ExtractIcon%(hInst%, lpszExeFileName$, niIndex%):"ExtractIconA"

.lib "user32.dll"
DrawIcon%(hDC%, x%, y%, hIcon%):"DrawIcon"
DestroyIcon%(hIcon%):"DestroyIcon"


BlitzSupport(Posted 2009) [#2]
I haven't tried it yet, but I believe you can get the icon's Bitmap structure via Win32's GetIconInfo, with the result from ExtractIcon.

With the information in the resulting ICONINFO -> HBITMAP structure, you could hopefully draw the result into a new image for direct use inside Blitz.