Solved

SHGetFileInfo takes a long time to get icon index for html-typed files for the first time

Posted on 2003-10-22
4
262 Views
Last Modified: 2013-11-20
I am writing a window program with CTreeCtrl to display file system in the computer. Both directory and file are displayed in the tree.

I use SHGetFileInfo to retrieve the icon index for the files.

SHFILEINFO sfi;
SHGetFileInfo(filepath, 0, &sfi, sizeof( sfi ), SHGFI_ICON | SHGFI_SMALLICON );

After program starts, if I clicked on a directory with html-typed file(s), it will take 3-5 seconds to display the expanded  tree. If the clicked directory does not contain any html-typed file(s), it will expand almonst instantly. After first time, the following expansion will happen much faster.

Thanks for your help.
0
Comment
Question by:htang_us
[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
  • 2
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 9600407
Indeed this is the case and there is no solution.  Depending on how the EXE files are physically structured, Windows may need to read through the file to locate the icon.  This, obviously, takes time.  You can see this (often annoying) behavior even in Windows Explorer and other Microsoft written apps.

If this is a problem for you, work out a caching scheme yourself so that you don't have to lookup the icons yourself every time.  You could use the ones you have from the cache and only read in any changed or new ones.
0
 
LVL 2

Author Comment

by:htang_us
ID: 9600514
Since SHGetFileInfo retrieves the icon index, the index for html file is 10 on my computer.
However, if I use 10 instead calling SHGetFileInfo, no icon will be displayed (SystemImageList has already be set in the CTreeCtrl.)

Is there anything special to these icon index?

thanks
0
 
LVL 32

Expert Comment

by:jhance
ID: 9600560
The icon index is related to the FILE in question.  So Windows must read the file, locate the 10th icon, and retrieve it.  Depending on where the icon is actually loaded in the file, it can take a while since disk activity is relatively costly in terms of execution time.
0
 
LVL 2

Author Comment

by:htang_us
ID: 9600604
jhance, Thanks for your answer to make my first question a happy one.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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