?
Solved

extract icon from .exe

Posted on 1999-11-07
5
Medium Priority
?
451 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:geeboy
  • 3
5 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 2189327
// Load exe or dll
HINSTANCE h=LoadLibraryEx(fileName,0,LOAD_LIBRARY_AS_DATAFILE);

Now you can use, say,

EnumResourceNames(h,RT_ICON,callbackProc,0)

to enumerate all icons.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2189328
You get icon names while enumeration. Use LoadIcon(h,iconName) to load icon itself.
0
 

Author Comment

by:geeboy
ID: 2189479
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.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2189839
Use ExtractIcon or ExtractIconEx.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2190008
>>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);
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question