Re: resolution + vbscript by Fosco
Fosco
Wed May 10 20:02:13 CDT 2006
"Damo_Suzuki"
VB6 :
news:microsoft.public.vb.general.discussion
Title Refresh the desktop's icons
Keywords desktop icon size, Registry, regedit
Categories Tips and Tricks, Windows
!!! WARNING !!!
Modifying the Registry can seriously damage your system. If you change the wrong values, you can make your system
unbootable. Don't mess with the registry unless you know what you are doing and make a backup first in any case.
Use the GetRegKeyValue function to get the current desktop icon size. Add one and use SetRegKeyValue to save the new
value. Then use SendMessageTimeout to broadcast a message telling all toplevel windows that a system setting has
changed.
Now change the icon size back. This process makes the toplevel windows refresh their icons.
See the code for details of how GetRegKeyValue and SetRegKeyValue work.
Private Sub cmdRefreshIcons_Click()
Dim icon_size_string As String
Dim new_icon_size_string As String
Dim result As Long
' Get the current icon size.
icon_size_string = GetRegKeyValue( _
HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size")
' Increase the value by 1.
new_icon_size_string = Format$(CInt(icon_size_string) + _
1)
SetRegKeyValue HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size", new_icon_size_string
' Send HWND_BROADCAST to refresh the icons.
SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, _
SPI_SETNONCLIENTMETRICS, 0&, SMTO_ABORTIFHUNG, _
10000&, result
' Restore the original value.
SetRegKeyValue HKEY_CURRENT_USER, _
"Control Panel\Desktop\WindowMetrics", _
"Shell Icon Size", icon_size_string
' Send HWND_BROADCAST to refresh the icons again.
SendMessageTimeout HWND_BROADCAST, WM_SETTINGCHANGE, _
SPI_SETNONCLIENTMETRICS, 0&, SMTO_ABORTIFHUNG, _
10000&, result
End Sub
--
Fosco