?
Solved

Extracting ICON from a DLL

Posted on 2002-07-18
20
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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
 
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 800 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

743 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