Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

update icons after registry change

Posted on 1998-07-16
12
Medium Priority
?
225 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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