Solved

Urgent desktop.ini problem

Posted on 2002-06-05
14
412 Views
Last Modified: 2010-04-04
Hi again,
I'm giving up all the points i've got let for this question (88 Point)...Sorry got no more points let, but i'm really desparate.

Here is my question.

I've created a desktop.ini file inside a folder and assigned an icon to it.

This is the code of the desktop.ini file:

[.ShellClassInfo]
IconFile=C:\WINDOWS\unlocked.ico
IconIndex=0

As i want to be able to change the icon, i've written a small test program with the following code:

(Note: 1 Button click changes to 1 folder icon and the otherchanges to the other.

Here it is:

procedure TForm1.Button1Click(Sender: TObject);


var
  hDesktop: HWND;
begin
  memo1.Lines.SaveToFile('C:\Windows\Desktop\Private\desktop.ini');

{NOW REFRESH THE DESKTOP}

  hDesktop := FindWindowEx(FindWindowEx(FindWindow('Progman', 'Program Manager'), 0,
    'SHELLDLL_DefView', ''), 0, 'SysListView32', '');
  PostMessage(hDesktop, WM_KEYDOWN, VK_F5, 0);
  PostMessage(hDesktop, WM_KEYUP, VK_F5, 1 shl 31);
end;

The memo contains the desktop.ini code.

It would work fine if it would refresh properly but it doesn't. :-(

Can anyone help me please? ...
I downloaded a program called E-Icons which does a very good refresh using DOS, but i don't know what to do anymore.

Please Help Me :-(



0
Comment
Question by:sfern
14 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7056755
Try ...

shellexecute(
 0,
 nil,
 pchar('rundll32.exe'),
 pchar('user,repaintscreen'),
 nil,
 sw_Hide);

instead.

Richard.

0
 

Author Comment

by:sfern
ID: 7056779
I've just tried it but it's not changing the Desktop folder icon although the desktop.ini file is pointing to it. :-(
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7056795
What icon are you changing?

The desktop icon inside Explorer?

Is the directory "private" correct? Should it be removed?
0
Technology Partners: 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!

 

Author Comment

by:sfern
ID: 7056812
It's not a special folder, i just want to be able to change the icon at will.
When you open the folder in explorer it is changed but does not change on the desktop, i just need a good refresh

Sfern
0
 

Author Comment

by:sfern
ID: 7056823
I'm trying to change the icon of a folder which resides on the desktop.


Sfern
0
 

Author Comment

by:sfern
ID: 7056829
Everytime i create a new folder and assign an icon to it for the first time it works, then...when you modify the desktop.ini file to point to another icon and refresh it, it does not change. :-(
0
 

Author Comment

by:sfern
ID: 7056842
Everytime i create a new folder and assign an icon to it for the first time it works, then...when you modify the desktop.ini file to point to another icon and refresh it, it does not change. :-(
0
 

Author Comment

by:sfern
ID: 7056847
Any way to refresh everything ?
0
 

Author Comment

by:sfern
ID: 7056849
Don't know what to try anymore :-(((((((((
0
 

Author Comment

by:sfern
ID: 7058191
can anyonemgelp please?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7058362
Try sending the message WM_SETTINGCHANGE?
0
 
LVL 1

Accepted Solution

by:
bes67 earned 88 total points
ID: 7059198
Hi

try this code. In it default large shell icon's size changed and then restored. As a result - desktop refreshed, but there is a side effect - your icons rearranged :( Anyway, here is a code

const REG_ICONSIZE_KEY = 'Control Panel\Desktop\WindowMetrics';


procedure TForm1.Button1Click(Sender: TObject);
var Reg: TRegIniFile;
    Val: string;
    res: DWORD;
begin
  Reg:=TRegIniFile.Create(REG_ICONSIZE_KEY);
  try
    Val := Reg.ReadString( '','Shell Icon Size','32');
  finally
    Reg.Free;
  end;

  Reg:=TRegIniFile.Create(REG_ICONSIZE_KEY);
  try
    Reg.WriteString( '','Shell Icon Size',IntToStr(StrToInt(Val) - 1));
  finally
    Reg.Free;
  end;
  SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
  0, SMTO_ABORTIFHUNG, 10000, Res);
  Reg:=TRegIniFile.Create(REG_ICONSIZE_KEY);
  try
    Reg.WriteString( '','Shell Icon Size',Val);
  finally
    Reg.Free;
  end;
  SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
                     0, SMTO_ABORTIFHUNG, 10000, Res);
end;

Hope this will help
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7061148
hum .. I don't have the refresh code in my app
but icon changing works everytime
here's the link to the complete project source:
http://lee.nover.has.his.evilside.org/isapi/pas2html.dll/pas2html?File=/delphi/Projects/AnyIcon
0
 

Author Comment

by:sfern
ID: 7061433
First of all thanks all for your help.
Icon.exe & source is for delphi 6 so couldn't make it work on mine but thanks anyway.


Now, the example from bes67 works fine, so i'll go for this one.

Thanks again

Sfern :-)


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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

762 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