Actualiser/Refresh IconCache

cs_AgentAmine Messages postés 28 Date d'inscription mercredi 24 juin 2009 Statut Membre Dernière intervention 11 avril 2012 - 8 mars 2011 à 22:45
cs_AgentAmine Messages postés 28 Date d'inscription mercredi 24 juin 2009 Statut Membre Dernière intervention 11 avril 2012 - 11 mars 2011 à 16:40
Salut tt,

je cherche un code pour actualiser le IconCache, malheureusement, il n'existe pas un API, mé j'ai trouve un code que me permet de faire ca, malheureusement aussi il ya disadvantage, les icones (du Bureau) sont réarranger :(

c'est le code (by Thomas Stutz)


uses
  Registry;

function RefreshScreenIcons : Boolean;
const
  KEY_TYPE = HKEY_CURRENT_USER;
  KEY_NAME = 'Control Panel\Desktop\WindowMetrics';
  KEY_VALUE = 'Shell Icon Size';
var
  Reg: TRegistry;
  strDataRet, strDataRet2: string;

 procedure BroadcastChanges;
 var
   success: DWORD;
 begin
   SendMessageTimeout(HWND_BROADCAST,
                      WM_SETTINGCHANGE,
                      SPI_SETNONCLIENTMETRICS,
                      0,
                      SMTO_ABORTIFHUNG,
                      10000,
                      success);
 end;


begin
  Result := False;
  Reg := TRegistry.Create;
  try
    Reg.RootKey := KEY_TYPE;
    // 1. open HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
    if Reg.OpenKey(KEY_NAME, False) then
    begin
      // 2. Get the value for that key
      strDataRet := Reg.ReadString(KEY_VALUE);
      Reg.CloseKey;
      if strDataRet <> '' then
      begin
        // 3. Convert sDataRet to a number and subtract 1,
        //    convert back to a string, and write it to the registry
        strDataRet2 := IntToStr(StrToInt(strDataRet) - 1);
        if Reg.OpenKey(KEY_NAME, False) then
        begin
          Reg.WriteString(KEY_VALUE, strDataRet2);
          Reg.CloseKey;
          // 4. because the registry was changed, broadcast
          //    the fact passing SPI_SETNONCLIENTMETRICS,
          //    with a timeout of 10000 milliseconds (10 seconds)
          BroadcastChanges;
          // 5. the desktop will have refreshed with the
          //    new (shrunken) icon size. Now restore things
          //    back to the correct settings by again writing
          //    to the registry and posing another message.
          if Reg.OpenKey(KEY_NAME, False) then
          begin
            Reg.WriteString(KEY_VALUE, strDataRet);
            Reg.CloseKey;
            // 6.  broadcast the change again
            BroadcastChanges;
            Result := True;
          end;
        end;
      end;
    end;
  finally
    Reg.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RefreshScreenIcons
end;


svp, m'aide pour trouver une solution sans réarranger les icones;
Merci d'avance;
AgentAmine;

1 réponse

cs_AgentAmine Messages postés 28 Date d'inscription mercredi 24 juin 2009 Statut Membre Dernière intervention 11 avril 2012
11 mars 2011 à 16:40
svp , une reponse, eske cé tres difficile ???
0
Rejoignez-nous