Solved

Urgent desktop.ini problem

Posted on 2002-06-05
14
411 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 57
Delphi Form ownership 4 110
QRReport  TQrmemo vertical stretching 1 52
update joined tables 2 55
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

791 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