Solved

Urgent desktop.ini problem

Posted on 2002-06-05
14
405 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:RQuadling
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:RQuadling
ID: 7056795
What icon are you changing?

The desktop icon inside Explorer?

Is the directory "private" correct? Should it be removed?
0
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now