News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

shell32 iconIndex

Started by maruf10, March 14, 2010, 04:49:05 PM

Previous topic - Next topic

maruf10

hello all ...
Assuming that i know the path of a file ... How can i get the icon index of that file using shell32.dll ??

This is an output of desktop.ini of folder icon
Quote
[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=3

locche

A bit late for a response, but if you are still interested. As you have already established the index, (index=3) I'm assuming you are asking how to access the icon you have indexed. If this incorrect, apologies. One way could be to use LoadLibrary for shell32.dll, and then to use ExtractIcon for the icon you want. For example ( code in C (masm32 on "to do" list)  ):
   HINSTANCE hInstance;
   HICON hIcon, hExIcon;
   LPSTR PathName[] = "C:\\Windows\\system32\\shell32.dll";
   ... 

   case WM_MYCOMMAND:
            hInstance = LoadLibrary(PathName);
            if ( hInstance )
            {
                      hExIcon = ExtractIcon(hInstance,PathName, index);
                           /* have handle, copy or whatever */
                      if ( hExIcon)
                           hIcon = CopyIcon(hExIcon);                           
             }
             FreeLibrary(hInstance);
            break;
     
  Good Luck

dedndave

use the forum search tool
this has been discussed at great length in previous threads
as i recall, it isn't a good idea to use shell32 icons directly, as the ordinals may change from one OS to another
but there is an API function that you can use

locche

to be perfectly honest, i don't understand why anyone would want to extract an icon from a microsoft product. They're far too ugly

Queue

They're the de facto standard for whatever it is the icon represents. So, by using Microsoft icons you're essentially standardizing your interface so people won't have to guess at what your icon represents.

Queue

dedndave

still....
there is an API to acquire those
better to use that for compatibility across OS's
the forum search tool is your friend
i am sure if you plug in "shell32 icon", you will get what you are after

locche

I see, lots of postings.  And yes, Queue I see the point. Of course there's always paint. I saw one posting where the user was lamenting the ugliness of self made icons. Attached is my rendition of the spraycan from paint. Whilst a study of H. Bosch's Weltgericht in mspaint might use up too much time, an icon can be achieved in a jiff. Not a pure copy like the attachment, but to see where to putpixels to convey a desired image. To this effect, I think one can easily make an ugly yellow folder bmp for LoadImage, etc. which still should look nicer than an MsIco, adress the problem of shifting indexes.  That's actually how I learned to create my first toolbars.