Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 22nd, 2006, 3:34 PM   #1
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
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.
Pedja is offline   Reply With Quote
Old Mar 22nd, 2006, 6:26 PM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 816
Rep Power: 4 The Dark is on a distinguished road
Google is your friend
The Dark is offline   Reply With Quote
Old Mar 22nd, 2006, 9:14 PM   #3
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
@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
Dameon is offline   Reply With Quote
Old Mar 23rd, 2006, 3:17 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Mar 23rd, 2006, 5:15 AM   #5
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 816
Rep Power: 4 The Dark is on a distinguished road
@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.
The Dark is offline   Reply With Quote
Old Mar 24th, 2006, 3:19 PM   #6
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
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);
App always blocks on second call to SendMessage function.
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?
Pedja is offline   Reply With Quote
Old Mar 24th, 2006, 6:23 PM   #7
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 816
Rep Power: 4 The Dark is on a distinguished road
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.
The Dark is offline   Reply With Quote
Old Mar 24th, 2006, 7:58 PM   #8
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Use PostMessage instead?

Sorry about the criticism of the link. I seem to have missed the first result...somehow.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Mar 25th, 2006, 8:03 AM   #9
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
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);
This function specifies the timeout period. After 5 seconds (in this case) program returns from the function, and icons are reloaded.
I still don't understand why the program never returned from SendMessage function, but it's not so important.
Thanks a lot.
Pedja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC