Board index » cppbuilder » Extracting Icon from an EXE

Extracting Icon from an EXE

    I am trying to get an Icon out of an EXE and display it. My goal is to
get it loaded into an ImageList.

    I have done this successfully in the past (VC 6.0) by using ExtractIcon
to get the icon handle and then placing the handle in the image list. I try
the same approach in C++ Builder 4 but the icon does not appear to load. To
be specific, I get the icon handle using ExtractIcon as I did in VC, and
then place the handle in a TIcon object. If I load the icon using
LoadFromFile and an arbitrary ICO file it works fine, but I need to get it
from the EXE.

    Any help would be appreciated,

    John Campbell

 

Re:Extracting Icon from an EXE


Hi John,

Quote
> I get the icon handle using ExtractIcon as I did in VC, and
> then place the handle in a TIcon object. If I load the icon using
> LoadFromFile and an arbitrary ICO file it works fine, but I need to get it
> from the EXE.

It's probably easiest to use the ImageList_Add() macro...

    ImageList1->Width = 32;
    ImageList1->Height = 32;

    HICON HIcon = ExtractIcon(HInstance, "C:\\Windows\\Notepad.exe", 0);
    ImageList_AddIcon((HIMAGELIST)ImageList1->Handle, HIcon);

HTH.

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Re:Extracting Icon from an EXE


ImageList_AddIcon()

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Other Threads