Solved

Extracting ICON from a DLL

Posted on 2002-07-18
20
263 Views
Last Modified: 2013-12-03
Hi,

I know how to use the ExtractIconEx function to get icon number 5 from a DLL.

the problem is it's only getting the first large icon and the first small icon.

I have an icon DLL where each icon is 48x48, 32x32, 16x16.

When I call the function I get the 32x32, I have no idea as for how to get the 48x48 version or even a 72x72 version.

can someone help with that ?

thanks
0
Comment
Question by:moshem
  • 8
  • 7
  • 2
20 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7164007
Do you have MSDN ?
If yes, then Find "Icons in Win32"
(don't  forget to put quotes(") in the end of the strings)

You can find a sampl that extracts the icon from the application/dll

Good Luck
0
 
LVL 1

Author Comment

by:moshem
ID: 7164236
I found that article before I posted the question, but it looks so complicated that I figured there must be a cleaner way.

is it ?

BTW,

roshmon, are you the only guy that answers win32 question ? where are all the other experts ? anyways, I'm glad you can be of assistance, you saved me quite a bit of time, thank!
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7164256
That is complex bcoz, that extracts cursors too...

But the code uses only simple memory functions and API.
Loading the icon, locking the memory, extracts the icons from that, writing to its icon format.

If you look at that deeply, you can study so many small things.

>> roshmon, are you the only guy that answers win32 question ? where are all the other experts ?

Nowadays, I'm refreshing the IE so many times, so I'm getting the questions first. You can see so many experts here with lakhs of points, this site is a wide network

Regards
Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7164266
"What's in an Icon?" in the document tells the icon structure, and the idea they followed.

ICON almost have the bitmap structure.

Roshmon
0
 
LVL 1

Author Comment

by:moshem
ID: 7164575
roshmon,

I have been unsuccessful in using the code in this document to extract an specific size version of a specific icon in an ".ICL" icon library.  can you help ? I'm willing to give 300 pts for this.

I need something like , open library X, get Icon number Y, get the 48x48 version of Y.


let me know

thanks!
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7164583
If you wait 2 more hours, I will try...

Regards
Roshmon
0
 
LVL 1

Author Comment

by:moshem
ID: 7164587
k, I'll keep trying myself until then, if I get it right I'll tell you, if I did not post any comment, please try...

0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7164788
Have you got the idea

The resource uses the structure for how many images stored.

typedef struct
{
     WORD               idReserved;   // Reserved
     WORD               idType;       // resource type (1 for icons)
     WORD               idCount;      // how many images?
     ICONDIRENTRY     idEntries[1]; // the entries for each image
} ICONDIR, *LPICONDIR;

This is the icon information

typedef struct
{
     BYTE     bWidth;               // Width of the image
     BYTE     bHeight;              // Height of the image (times 2)
     BYTE     bColorCount;          // Number of colors in image (0 if >=8bpp)
     BYTE     bReserved;            // Reserved
     WORD     wPlanes;              // Color Planes
     WORD     wBitCount;            // Bits per pixel
     DWORD     dwBytesInRes;         // how many bytes in this resource?
     DWORD     dwImageOffset;        // where in the file is this image
} ICONDIRENTRY, *LPICONDIRENTRY;


these are the two structures used in ICON files.

If you want to load icon from an EXE,  

We can use LoadLibraryEx
By getting the hInstance of the EXE, you can load the resource using LoadResource.

"LockResource" gives the memory pointer of the resource.

So casting it into LPICONDIR, gives the No. ocon, etc informations.

By getting the count, looping through idEntries[],
idEntries[] id the IDS of the Images

So using this ID we are finding (FindResource) loading the resource,

Locking resource get the data of the icon for the current id(idEntries[i]).

Going through "ReadIconFromEXEFile" , you can get a better start.

Good Luck

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:moshem
ID: 7165311
I did try that, sort of, I'll give it another try and let you if it works now.
0
 
LVL 1

Author Comment

by:moshem
ID: 7168078
nope, still can't get it to work...
0
 
LVL 1

Expert Comment

by:Munim
ID: 7224555
I can give you the answer. Will it be Okey if I answer the question with Visual Basic or Delphi code...
0
 
LVL 1

Author Comment

by:moshem
ID: 7225224
No, it wont be usefull for me, i need it in C/C++

thanks
0
 
LVL 1

Expert Comment

by:Munim
ID: 7225337
It is all about API. I cannot understand, how do u work with VC++, if you dont understand API
0
 
LVL 1

Author Comment

by:moshem
ID: 7225341
you can try & send it, I'll try to convert it to C++, if I can and it works - the points are yours
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 200 total points
ID: 7238296
Hi Moshem,
     Sorry for the delay...

     try this link

http://www.codeproject.com/useritems/Icon_Viewer.asp

Roshmon
0
 
LVL 1

Author Comment

by:moshem
ID: 7316784
roshmon, please answer this question so I can give you the points
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9018811
What about my prev. comment? Checked that link? :-)

Roshmon
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now