How to force Windows desktop background to update or refresh
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
- Open Task manager
- Kill explorer.exe
- If the shell doesn't immediately restart
- From the menu select File > New Task
- Type "explorer.exe" and hit enter.
I was trying to do something similar - update a registry setting for the start menu and then immediately have the start menu reflect the changes.
The solution from this MSDN question worked for me perfectly.
You could try broadcasting a
WM_SETTINGCHANGE
message. For example:
class Program
{
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult);
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
static void Main(string[] args)
{
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
}
}