Solved

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

Posted on 2003-10-22
4
259 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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 102
Strange date stored 22 174
matchUp  challenge 6 76
wordmultiple challenge 12 156
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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