[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Rebuilding the Windows Icon Cache

Posted on 2001-07-01
5
Medium Priority
?
904 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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