?
Solved

update icons after registry change

Posted on 1998-07-16
12
Medium Priority
?
218 Views
Last Modified: 2010-04-04
Hi! I've successfully wrote to the registry a working
extension association (using internal identifiers and
everything) now I need to have all top level windows
update their icons to reflect this change.
I've tried all the related WM_xxx commands with the
sendmessage(HWND_BROADCAST function along with every
parameter combination possible. WM_SETTINGCHANGE comes
the closest to working - I see something try to happen
but no cigar. Maybe its all in the lParam but I've
tried all related registry keys. I've even considered
things such as sending the F5 key to all windows
or if I only knew explorers menu ID for 'Refresh'...
but then theres the risk of obvious havoc from other
apps. And using FindWindow to find all explorers is a
trick too because the caption contains its current
path. Even all this is no good because of the need to
update desktop icons and such.
I've seen other apps do global refreshs and icon
rebuilds before, and Windows itself does a snappy job
of this when setting associations through its own
filetype editing dialog.
What gets me is that it must be something simple...
0
Comment
Question by:amber45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357969
Thus this work?
procedure TForm1.Button1Click(Sender: TObject);
                          begin
                               SendMessage(FindWindow('Progman', 'Program Manager'), WM_COMMAND,
                          106597, 0);
                          end;
Zif.
0
 

Author Comment

by:amber45
ID: 1357970
Hi ZifNab! no, it didnt work. it looks as though the desktop
gets refreshed a little bit but no icons change. I put a wav
file right on my desktop to work with. but the only way it will
update is if I highlight it and hit F5.
The explorer remains untouched.
If I run your snip again and again, windows seems to do some
kind of bigger refresh eventually that does it OK, but even
then not every time.

What does the '106597' stand for - a menu ID? I knew the old
Program Manager still resides somewhere deep in 95 but I didnt
know you could still send it messages. Is it embedded into the
desktop now or something? I know I can run progman.exe and stuff
but how is it already running and eccepting messages otherwise?
 
Very interesting in all but this seems like the wrong direction.
Thanks for trying!
0
 

Author Comment

by:amber45
ID: 1357971
Is this one too tough for the experts???
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:AJFleming
ID: 1357972
I've not tried this, but how about doing an

UpdateWindow(GetDesktopWindow);

later,
   Adam...
0
 

Author Comment

by:amber45
ID: 1357973
just tried it and it doesnt work. I'm also trying RedrawWindow
but that doesnt seem to work either although I'm not sure if I
have it coded right. Has anybody successfully used the
RedrawWindow command? Both this and the UpdateWindow uses the
WM_PAINT message which I'm not even sure refreshes icons.

0
 
LVL 2

Expert Comment

by:k6__
ID: 1357974
try to do a SENDMESSAGE with WM_WININICHANGE.

i think this is working =)



0
 

Author Comment

by:amber45
ID: 1357975
sorry k6, tried that too. I even wrote to the win.ini the
correct data and everything as well. still nothing.
I'm starting to think this must be some kind of secret microsoft
command or something...

I've tried all this on several machines to make sure its not a
fault of my machine - but if anybody has tried anything here and
made it work on yours, be sure to let me know! ;)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357976
Hi amber45,

found this somewhere on the net, give it a try :

this seems to work:

                             procedure Tfrom1.updateicons;
                             var dtwh : hwnd;
                                 p1, p2 : pchar;
                                 s1, s2 : string;
                             begin
                               s1 := 'Progman';
                               s2 := 'Program Manager';

                               getmem(p1, length(s1)+1);
                               getmem(p2, length(s2)+1);
                               strpcopy(p1, s1);
                               strpcopy(p2, s2);

                               dtwh := FindWindow(p1,p2);

                               freemem(p1, length(s1)+1);
                               freemem(p2, length(s2)+1);

                               sendmessage(dtwh, wm_command, $A065, 0);
                             end;

Zif.
0
 

Author Comment

by:amber45
ID: 1357977
hey Zif! isnt that essentially the same as your first response?
only the wparam differs. Do you think focusing on the progman thing is still the key? it still doesnt work although playing
with that wparam value does some very interesting things!

The closest to actually refreshing anything comes from this:

sendmessage(hwnd_broadcast, WM_command, $A065, 0);

it seems as though your $A065 does indeed refresh drive data and
tree views in explorers, but not the file list or icons.
It doesnt seem to do anything when used with the progman thing.
Does it really work for you?

playing around I found a couple other params that effect explorer
when used with the above line of code-
$A062 will hide the toolbar and A063 hides the status bar. :]

Still these seem to all be explorer recognized commands. The
desktop and the rest of windows remains untouched.

I'm still curious about the Program Manager reference you make
and how its involved, Zif. Whats the dilly?

Amber
0
 
LVL 1

Accepted Solution

by:
timop earned 800 total points
ID: 1357978
You must call

uses  ShlObj;

SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_FLUSH, nil, nil );

0
 

Author Comment

by:amber45
ID: 1357979
Thats it, timop!!!!!!! I didnt know of the SHChangeNotify...
lots of other neat flags in there too! I'm also going to have to
take a deep look into shlobj.

Thanks a ton, timop, I wish I could buy you a beer! but
the points will have to do for now! and thanks everyone for your
suggestions. (I'd still like to know what else you know about
the progman thing, Zif :)

amber

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357980
amber, not much... Glad prob. is solved now, have a nice day, Zif.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 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