Link to home
Start Free TrialLog in
Avatar of sfern
sfern

asked on

Urgent desktop.ini problem

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 :-(



Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Try ...

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

instead.

Richard.

Avatar of sfern
sfern

ASKER

I've just tried it but it's not changing the Desktop folder icon although the desktop.ini file is pointing to it. :-(
What icon are you changing?

The desktop icon inside Explorer?

Is the directory "private" correct? Should it be removed?
Avatar of sfern

ASKER

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
Avatar of sfern

ASKER

I'm trying to change the icon of a folder which resides on the desktop.


Sfern
Avatar of sfern

ASKER

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. :-(
Avatar of sfern

ASKER

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. :-(
Avatar of sfern

ASKER

Any way to refresh everything ?
Avatar of sfern

ASKER

Don't know what to try anymore :-(((((((((
Avatar of sfern

ASKER

can anyonemgelp please?
Try sending the message WM_SETTINGCHANGE?
ASKER CERTIFIED SOLUTION
Avatar of bes67
bes67

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of sfern

ASKER

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 :-)