I just ran across this trick the other day and thought others may find it useful. When explorer crashes you lose the icons in the system tray. Ever since internet explorer 4, windows has begun sending a message out to all top level windows every time the system tray is recreated. This gives you a chance to re-add your tray icon after explorer restarts. You must register the "TaskbarCreated" message and then when it is received in the WndProc just recreate your tray icon. Here is an example:



.data
szTaskbarCreated db "TaskbarCreated",0

.data?
s_uTaskbarRestart dd ?

...

invoke RegisterWindowMessage, ADDR szTaskbarCreated
mov s_uTaskbarRestart, eax


Just look for a message in WndProc with the same value as s_uTaskbarRestart and recreate your icon if you get it.
Posted on 2002-02-05 23:12:14 by rdaneel
wow very nice gem thanks for sharing. you should post this in the algorithms/source.

edit: i just tested my programs in the system tray to see which ones would recover there icons and they all failed miserably. although windows 2000 explorer doesnt nearly crash as much as my windows 98 did it still crashes and this code is a wonderful surprise.:alright:
Posted on 2002-02-05 23:42:06 by smurf