Solved

Urgent desktop.ini problem

Posted on 2002-06-05
14
401 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

13 Experts available now in Live!

Get 1:1 Help Now