![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
|
Changing icons problem
Hi there.
I have a problem. When I change the default icon for some file extension, I need it to happen instantly. For example, I want to change icon for .cdc files. I know how to do it, and that is not a problem, but the problem is that it doesn't happen instantly, but when some kind of system refresh happens. I think it has something to do with shelliconcache.dll or iconcache.db, witch i can't find on my system. I have WXP Professional. For example, when you start BS Player and assign it to be the default player for some file types, it happens, and all icons change right away. I need to know what I can do to make this change happening when I want it. What is the thing that BS player and Windows Media Player do when they make a registry change, to make it happen at that exact moment? The thing is that i am creating an application that should be able to do this, and i have no idea what should be done, and how BS Player does it. Maybe I need to send some kind of system message to tell the OS to reload icon cache. Any help would be most appreciated. Thanks. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
|
|
|
|
|
|
#3 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
@The Dark: I'd have to say, that link is far from useful.
I haven't been able to find a good answer. Odd.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
I know that the tweakUI powertool rebuilds your icons just for that purpose.
I think you need to do the same.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
@Dameon: Really? The first link off google (the codeproject one) shows a similar problem with changing the icons and shows the exact call needed to get the icon cache to be refreshed.
::SendMessage(HWND_BROADCAST ,
WM_SETTINGCHANGE,SPI_SETNONCLIENTMETRICS,NULL);I suspect that there is a better SPI_ value for icon changing, but this one (suposedly) does the trick. |
|
|
|
|
|
#6 |
|
Programmer
|
Guys, thank you all for helping, especially The Dark (again).
You got it right, but i still have a problem. ShellIconChanger really works, and it does what my app needs to do, but i have problems implementing the same in C#. Here is what happens: [DllImport("user32.dll")]
public static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);RegistryKey k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
k.SetValue("Shell Icon Size", "33"); //this value in my reg is 32
k.Flush(); k.Close();
SendMessage((IntPtr)0xffff, 0x001A, 0x002A, IntPtr.Zero);
k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
k.SetValue("Shell Icon Size", "32"); //back to what it was
k.Flush(); k.Close();
SendMessage((IntPtr)0xffff, 0x001A, 0x002A, IntPtr.Zero);Icons sometimes change immediately, and sometimes don't. From my app, icons change immediately only when I start it after doing the same thing in ShellIconChanger. Every other time app fails to do this. What am I missing? |
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
It may be the fault of another program you are running. If an app doesn't respond to the global SendMessage, it sits there waiting for it for a period of time. I am not sure what you can do about it though.
|
|
|
|
|
|
#8 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Use PostMessage instead?
Sorry about the criticism of the link. I seem to have missed the first result...somehow.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#9 |
|
Programmer
|
It works! The SendMessageTimeout function does the trick.
private static extern long SendMessageTimeout( int hWnd, int Msg, int wParam, string lParam, int fuFlags, int uTimeout, out int lpdwResult ); RegistryKey k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
k.SetValue("Shell Icon Size", "33");
k.Flush(); k.Close();
int res = 0;
SendMessageTimeout(0xffff, 0x001A, 0, "", 0x0002, 5000, out res);
k = Registry.CurrentUser.OpenSubKey("Control Panel").OpenSubKey("Desktop").OpenSubKey("WindowMetrics", true);
k.SetValue("Shell Icon Size", "32");
k.Flush(); k.Close();
SendMessageTimeout(0xffff, 0x001A, 0, "", 0x0002, 5000, out res);I still don't understand why the program never returned from SendMessage function, but it's not so important. Thanks a lot. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|