Re: Offset of icons in exe files
I had missed ExtractIconEx completely.
Are you saying that the HICON is pointing to a 4 or 8 bit but GetBitmapBits
retuns a 32 bit bitmap?
Have you tried calling ::GetBitmapBits on the HICON directly?
I guess you could always create a 4 or 8 bits bitmap and draw the Icon on it
and then do GetBitmapBits.
AliR.
"Kai Sandner" <ks@polycolor.de> wrote in message
news:7a2cc53e-cc51-49c7-9ffb-585aba197603@i76g2000hsf.googlegroups.com...
On 17 Jul., 20:18, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
You can always load the Icon, get the handle, convert it to a bitmap, and
then use GetDIBits to get the bits.
That would be something like this:
HICON hIconLarge, hIconSmall;
int numIcons = ExtractIconEx(pathoffile, 0, &hIconLarge, &hIconSmall,
1);
ICONINFO oIconInfoS;
GetIconInfo(hIconSmall, &oIconInfoS);
BYTE barry[4096];
CBitmap Bmp;
CBitmap* pHBmp;
pHBmp = Bmp.FromHandle(oIconInfoS.hbmColor); //pHBmp is 32 Bit!
pHBmp -> GetBitmapBits(isbS, barryS);
So the buffer had to be converted back to 4 or 8 Bit to
receive (maybe) the original.
I am not aware of a suitable algorythmen for that.
Therefore I thought it might be easier to browse through the
PE headers and find the icon offsets.
But they don?t seem to contain offset information.
Kai Sandner