Exctracting an icon from an EXE

L

Laurent Navarro

Hello,


I have an EXE (.NET assembly) file with an icon which has 8 formats
(128x128, 96x961, ..., 24x24 and 16x16). I would like the extract the
128x128 sized icon only to display it on a PictureBox control.

I made some searchs and discovered that the Icon.ExtractAssociatedIcon()
function can do what I want, but only for the smallest icon size, ie 16x16
here... I tried Assembly.GetManifestResourceStream() also but I didn't
either find a way to extract the specified size.

Is there a way to extract that 128x128 sized icon that I missed, even
with Windows API ?


Thanks for any help :)
 
M

Mike Spike

Yes there is a shell32 API:
ExtractIcon() check MSDN online
But also there is a ICON class in the System.Drawing namespace that wraps
this for you.

Mike.
 
L

Laurent Navarro

Mike,


Thanks for your answer. The ExtractAssociatedIcon() function I
mentionned is a method of the System.Drawing.Icon class... but I didn't see
any way to extract a specified icon size. Maybe will I be luckier with the
ExtractIcon() function... I'll dig deeper.

Laurent
 
M

Mike Spike

Ah, yeah, you can specify the size in the actual Windows API call, this is
yet another example of microsoft wrapping an API call in class and then not
exposing the usefull parameters.

: 0 (

You do this by specifying a Parmeter and leaving another blank.

like: GetIcon(exename, handle, 0, 1)

where the 3rd parameter is for getting the small icon and the 4th is for
getting the large one and visa versa etc.

Mile
 
L

Laurent Navarro

Hi Mike,


I tried the ExtractIcon() and ExtractIconEx() functions. On the second
one, I have the parameters you said which can be used to select a small size
or a large size... But when I select the small size, I get the 16x16 icon,
and when I select the large size I get the 32x32... What I would like to get
is the 128x128 icon...

Is that possible ?

Thanks

Laurent
 
M

Michael M.

It must be possible, I have looked at Shell32.dll and can not see a newer
function for this.

Mabye download a trial of an Icon Extraction program and open it with
"DEPENDS.EXE" from microsoft it will show you all the functions the EXE
image is linking to.

Regards,
Mike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top