Link to home
Start Free TrialLog in
Avatar of geeboy
geeboy

asked on

extract icon from .exe

Hello:

I want to extract a .exe's icon and add to my listview.
The problem is:
I can use SHGetFileInfo() to get the system-wide registered icon in the registry,but I can not get the icon of those .exe which are not registerd.

BUt I find exploer can do this.HOw to?
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickRepin
NickRepin

You get icon names while enumeration. Use LoadIcon(h,iconName) to load icon itself.
Avatar of geeboy

ASKER

First ,thank you very  much for answering me two questions!
...............
but
Does explorer use this way?

I sole goal is to show some .exe into my listview and add it's icon beside the name.So,as you said,I need loadlibray for every .exe?

And I don't know which icon I need,I only want to show the icon of the .exe which the Explorer show.

So,I only need one icon to show.For example,if I write a .exe and when I view it in the Explorer,there is an icon beside the name of my .exe,how to extract that icon?

Regards.
Use ExtractIcon or ExtractIconEx.
>>Does explorer use this way ?

Nobody knows this except Microsoft. Most likely, it uses ExtractIcon().

>>I need loadlibray for every .exe?

chensu's suggestion is more easy to implement.

You can use just

HICON hIcon=ExtractIcon(hYourAppInstance,fileName,0);