?
Solved

Rebuilding the Windows Icon Cache

Posted on 2001-07-01
5
Medium Priority
?
892 Views
Last Modified: 2007-12-19
Does anyone have any clues about how to programmatically rebuild the Icon Cache.
I am currently involved with developing an upgrade of a program. This new version has a new icon, so I want the program to be able to rebuild the Icon Cache when it is first installed so the old shortcuts get the new icon...

I don't want to delete the SHELLICONCACHE file. Anyone know how TweakUI does it???

Cheers,
Greg
0
Comment
Question by:gwhite012597
[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
  • 3
5 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 800 total points
ID: 6243366
hi,
you can use this procedure to rebuild the icons:

Regards Barry

uses registry;

procedure RebuildIcons;
var
  Registry: TRegistry;
  OldSize: integer;
 dwResult: cardinal;
const
  SShellIconSize = 'Shell Icon Size';
  Timeout = 1000;
begin
  Registry := TRegistry.Create;
  try
    if not Registry.OpenKey('Control Panel\Desktop\WindowMetrics', False)
then
      MessageBeep(0);
    if Registry.ValueExists(SShellIconSize) then
      OldSize := StrToInt(Registry.ReadString(SShellIconSize))
    else
      OldSize := 0;
    Registry.WriteString(SShellIconSize, IntToStr(OldSize + 1));
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
      SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, Timeout, dwResult);
    if OldSize > 0 then
      Registry.WriteString(SShellIconSize, IntToStr(OldSize))
    else
      Registry.DeleteValue(SShellIconSize);
    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
      SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, Timeout, dwResult);
    Registry.CloseKey;
  finally
    Registry.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
RebuildIcons;
end;
0
 
LVL 17

Expert Comment

by:inthe
ID: 6243378
timeout may want to be longer (5000) maybe ..
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6243379
Uses ShlObj;

  SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_FLUSHNOWAIT or SHCNF_FLUSH or SHCNF_PATH,nil,nil);
  SHChangeNotify(SHCNE_UPDATEIMAGE,SHCNF_FLUSHNOWAIT or SHCNF_FLUSH or SHCNF_PATH,nil,nil);
0
 
LVL 17

Expert Comment

by:inthe
ID: 6243385
impressive ;-)
0
 

Author Comment

by:gwhite012597
ID: 6247958
Thanks for the help. Both answers are good. I think I prefer the two liner :) but I'm going split the points. Is that OK with you guys??

Cheers,
Greg
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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