The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: maruf10 on March 14, 2010, 04:49:05 PM

Title: shell32 iconIndex
Post by: maruf10 on March 14, 2010, 04:49:05 PM
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
Title: Re: shell32 iconIndex
Post by: locche on July 04, 2010, 04:46:55 PM
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
Title: Re: shell32 iconIndex
Post by: dedndave on July 04, 2010, 06:18:28 PM
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
Title: Re: shell32 iconIndex
Post by: locche on July 04, 2010, 06:47:20 PM
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
Title: Re: shell32 iconIndex
Post by: Queue on July 04, 2010, 06:51:06 PM
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
Title: Re: shell32 iconIndex
Post by: dedndave on July 04, 2010, 10:56:56 PM
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
Title: Re: shell32 iconIndex
Post by: locche on July 05, 2010, 11:39:45 PM
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.