Mirror

Refresh the Windows Desktop (Views: 704)


Problem/Question/Abstract:

How can I refresh the Windows desktop after I have set a new background image in the registry?

Answer:

Solve 1:

I want to post this article because I sure that this question can ask a lot of developers but to find an answer is not easy task.

So if you need refresh a desktop in run-time, you can execute a next procedure:

uses ShlObj;
{...}
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);

This code will refresh a desktop image and re-read the icons for files with registered extentions.

PS: you can do a same if you press a right mouse button on desktop and select Update item.

Solve 2:

procedure TForm1.Button1Click(Sender: TObject);
begin
  SendMessage(FindWindow('Progman', 'Program Manager'), WM_COMMAND, 106597, 0);
end;

This has the same effect as pressing F5 in Explorer.

<< Back to main page