Solved

update icons after registry change

Posted on 1998-07-16
12
202 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System restore point 4 91
Thread safe  opinion 7 126
indy Tidtcpserver best  way to brodcast message to multiable clients 1 145
Best Firemonkey component pack 1 86
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

16 Experts available now in Live!

Get 1:1 Help Now