

InterviewSolution
Saved Bookmarks
1. |
Solve : Desktop Refresh? |
Answer» Does anyone know how to refresh their desktop with vba?? can't believe that a simple microsoft function may have not been covered.....You could try this: Code: [Select]Private Sub cmdRefreshIcons_Click() ' routine to refresh the desktop. ' copied from (URL address BLOCKED: See forums rules) 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 just be careful when modifying registry. You could render your computer useless, until re-install of OS. Re-installing OS just about solves everybodies problems lol. no joy my friends, what about a script that does a specific folder - could try doing it on the desktop folder instead???You might try to get a handle for the DESKTOP folder and use the sendkeys method of the shell object to mimic F5. Code: [Select]Set WSHShell = WScript.CreateObject("WScript.Shell") strDesktop = WSHShell.SpecialFolders("Desktop") WSHShell.AppActivate strDesktop WSHShell.SendKeys "{F5}" STILL no word on why you'd do this from within an application. 8-) Edit: found this solution on the net; it's still written in VBScript not VBA though |
|