• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Extracting ICON from a DLL

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
moshem
Asked:
moshem
  • 8
  • 7
  • 2
1 Solution
 
Roshan DavisCommented:
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
 
moshemAuthor Commented:
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
 
Roshan DavisCommented:
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
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Roshan DavisCommented:
"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
 
moshemAuthor Commented:
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
 
Roshan DavisCommented:
If you wait 2 more hours, I will try...

Regards
Roshmon
0
 
moshemAuthor Commented:
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
 
Roshan DavisCommented:
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
 
moshemAuthor Commented:
I did try that, sort of, I'll give it another try and let you if it works now.
0
 
moshemAuthor Commented:
nope, still can't get it to work...
0
 
MunimCommented:
I can give you the answer. Will it be Okey if I answer the question with Visual Basic or Delphi code...
0
 
moshemAuthor Commented:
No, it wont be usefull for me, i need it in C/C++

thanks
0
 
MunimCommented:
It is all about API. I cannot understand, how do u work with VC++, if you dont understand API
0
 
moshemAuthor Commented:
you can try & send it, I'll try to convert it to C++, if I can and it works - the points are yours
0
 
Roshan DavisCommented:
Hi Moshem,
     Sorry for the delay...

     try this link

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

Roshmon
0
 
moshemAuthor Commented:
roshmon, please answer this question so I can give you the points
0
 
Roshan DavisCommented:
What about my prev. comment? Checked that link? :-)

Roshmon
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.

  • 8
  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now