Link to home
Start Free TrialLog in
Avatar of MonkeyLin
MonkeyLin

asked on

How to rebuild iconcache like this software:Rebic?

see:http://www.virtualplastic.org/html/icn_sys.html#2

Rebuild the icon cache
This is a feature of some of these and other apps. What's being done is, the hidden "shelliconcache" file (no extension, and a hidden file) in your windir gets deleted. This cache gets corrupted once in a while. You can do that yourself but you'll need to restart to refresh explorer, and to recreate the file. This function refreshes explorer and the file immediately.

It's also available as a standalone program. RebIC removes any old images from memory and is available from ArcaneWooD Software (free, Win 9x). Great when you've been fooling around without using any app: put a shortcut in your quicklaunch bar (add "-close" to the path).

 
Avatar of KDivad
KDivad

Easy, though I've lost the source to a control I built this into. The idea is as follows:

1. Modify the "Shell Icon Size" value in the registry in the key "HKCU\Control Panel\Desktop\WindowMetrics".
2. Use SendMessage to tell the system that a system metric has been altered (constant unknown).
3. Restore the value from step 1.
4. Repeat step 2.

I'll see if I can find my actual code, but I'm pretty sure I've lost it.
Nope, I don't see it anywhere. The control I used it in is apparently all I have left of it. Since it's compiled to Native code, I can't retrieve it either... <sigh>
Avatar of MonkeyLin

ASKER

Good!And now,I only want to know: How to tell the system that a system metric has been altered...
kDivad,Thank you!
If I can remember it, I'll let you know. But I've had no luck so far. I've been trying to rewrite that component and this is the only thing I haven't yet figured out...
I'll waiting ...Thank you!
I did remember another part. You need to lock the desktop before the code executes to prevent massive flickering.

Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long

LockWindowUpdate GetDesktopWindow
'Do the flushing from earlier post
LockWindowUpdate 0

Still trying to find or remember that code...
Still waiting...
I think I've got part of it. I've got another constant to track down before I can try it though.

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const HWND_BROADCAST = &HFFFF&
It was supposed to be:

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&
This may be it:

Public Const WM_WININICHANGE = &H1A

I'll give it a shot tomorrow, I've got to get to bed...
Nope, not it. Or at least, it's partially not it. Will keep looking.
It's the code right?
when I use the code, program die??
Private Const WM_WININICHANGE = &H1A
Private Const WM_SETTINGCHANGE = WM_WININICHANGE
Private Const HWND_BROADCAST = &HFFFF&
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub Command1_Click()
Dim tmpstr As String
tmpstr = GetStringValue("HKEY_CURRENT_USER\Control Panel\desktop\WindowMetrics", "Shell icon size")
SetStringValue "HKEY_CURRENT_USER\Control Panel\desktop\WindowMetrics", "Shell icon size", CStr(CLng(tmpstr) + 1)
SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
SetStringValue "HKEY_CURRENT_USER\Control Panel\desktop\WindowMetrics", "Shell icon size", tmpstr
SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
End Sub
Keep waiting...
ASKER CERTIFIED SOLUTION
Avatar of KDivad
KDivad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I know how to do it!!!
Do not use
SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
Try this:
whwnd = FindWindow("progMan", "program manager")'GetDesktop?
SendMessage whwnd, WM_SETTINGCHANGE, 0, 0

This problem is too hard.It take me about three month's time.I'm so happy now.

Thank you for your help!!!

Well,GetStringValue and SetStringValue are custom Functions.

Thank you again!!
Really thank you!
It works now? Awesome! Congratulations! Now, I can finally finish rebuilding that project.

We both got what we needed from this one. Makes the trouble worth it, doesn't it?

Later,
KDL