extract icon from .exe


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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

// Load exe or dll

Now you can use, say,


to enumerate all icons.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You get icon names while enumeration. Use LoadIcon(h,iconName) to load icon itself.
geeboyAuthor Commented:
First ,thank you very  much for answering me two questions!
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?

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);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.