Solved

update icons after registry change

Posted on 1998-07-16
12
199 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
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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 200 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

707 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

19 Experts available now in Live!

Get 1:1 Help Now