[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Urgent desktop.ini problem

Posted on 2002-06-05
14
Medium Priority
?
429 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 352 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

872 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