Hey everybody,
I'm working on a directory browser and I wanna show icons next to file names. For the most part this is working really well. However, I'm using ExtractIcon for .exe files and it's sorta slow.

It's mostly noticeable when I open up a large directory such as c:\windows (where on my drive there are 98 executables). It takes about 8 seconds to load up that directory. If however, I replace the call to ExtractIcon with something like mov eax,hIcon it's pretty much instantaneous.

So, I'm wondering if people know of a good way of loading lots of icons from executables.

I'm thinking of writing a replacement for ExtractIcon (something like create a file mapping to the exe and "pull out" the icon. Although I'm not entirely sure what I should do to do this)

Any ideas are appreciated
Thanks
--Chorus
Posted on 2002-07-14 10:58:17 by chorus
SHGetFileInfo
Posted on 2002-07-14 12:41:43 by comrade
Posted on 2002-07-14 12:45:13 by bazik
Thanks guys,

That's a lot faster...

I find there's a little bug though... probably something I'm doing wrong. In large directories some of the icons don't draw (dirs w/ 600+ files)

I'll look into it..

thanks again
--Chorus
Posted on 2002-07-14 13:47:30 by chorus
This function seems to return a different handle to each icon even if they are the same. Ex. suppose I have a directory of txt files. Each file gets the same picture, but if I output the value of the hIcon every one is unique.

Is this something to be concerned about?

Also, in dirs with more than 128 files only the first 128 get handles. The remaining files get a 0 handle. Are these things related?

I think I'll have to work out something where I just load icons for file certain file types and cross-reference the extension with a list instead of calling SHGetFileInfo on every entry...

--Chorus
Posted on 2002-07-14 15:05:45 by chorus
Why do you want to extract the icons at all?
I saw programs with file list boxes, wich automatically showed the right icon, without special loading of it :)

IIRC, Ewayne has a (open source) file manager on his site wich does that.
Posted on 2002-07-14 16:19:55 by bazik
SHGetFileInfo can create a new copy of the file icon for you, or it can give you an index to it in the system image list which you can assign to your listview (make sure it assign it as SHARED). The latter one is obviously faster and more efficient.
Posted on 2002-07-14 22:44:07 by comrade
bazik, I'm trying to implement my own file browser. I'll look into Ewayne's program, but there are things that I want to do that I don't think regular file lists were made for (ex. I want to be able to "browse" into zip files the same way I would a directory)

By designing my own file list I can really do what I want to do, and if I need to in the future, add some new functionality. Plus, it's just fun to see what works/doesn't work, etc. I'm sure you know what I mean.

Comrade, I'm now using the imagelist way of doing things and it is faster. Furthermore, like files get like values of iIcon and hImageList. (unlike before, where hIcon was different for every file)

Strangely though, it still cops out after 128 file names. It only seems to do this at work, but not at home. (Both machines are win98). I guess it just needs some tweaking :)

Thanks again guys
--Chorus
Posted on 2002-07-15 13:30:40 by chorus
Why is SHGetFileInfo faster then ExtractIcon? Im in the need of loading
alot of icons from files. But I need to load a specific icon in the files.
Some files I may need to load icon number 3 in the file etc.

If the SHGetFileInfo api is faster? then how can I specify the
icon I want to load? maybe im just blind and didnt see it in the
api reference. Anyways, I always appreciate a kick in the right
direction! :alright:
Posted on 2003-01-07 22:36:52 by natas
SHGetFileInfo uses the system's icon cache, so it doesn't have to open every file. It just looks at the extension and pulls the icon from the cache.
Posted on 2003-01-08 01:05:22 by Qweerdy
<off-topic>

The tool "Graphic Stealer Pro" extracts and displays all the icons.

</off-topic>

Regards,

Vortex
Posted on 2003-01-08 03:59:12 by Vortex
Thanks for the info Qweerdy! thats good to know. The reason I needed
to extract a specific icon from a resource is because im just coding a small
File Type enumerator and I need to load all the icons for each filetype.
This was actually very easy todo with that function. I just used the extension
and not a fullblown filename for input. Works like a charm! ( ;) )
Posted on 2003-01-08 04:04:27 by natas