- May
- 13,211
- 180
My guess is that the refresh is hardcoded in TCMD (and I would love to know how it's done; For some scripted deployment I need exactly that: a command-line tool to refresh Explorer Desktop+filemanager ..)
Just a guess ... maybe by letting the system know that a change has been made ... something similar to what's done when TCC modifies the system or user environment, perhaps with a different string as LPARAM:
Code:
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, &dwReturn);
As for simply refreshing the desktop, this is crude, but it works.
Code:
HWND hWndProgman, hWndShell, hWndFolder;
if (
(hWndProgman = FindWindowEx(GetDesktopWindow(), 0, L"Progman", NULL)) != NULL
&& (hWndShell = FindWindowEx(hWndProgman, 0, L"SHELLDLL_DefView", NULL)) != NULL
&& (hWndFolder = FindWindowEx(hWndShell, 0, L"SysListView32", NULL)) != NULL
)
{
PostMessage(hWndFolder, WM_KEYDOWN, VK_F5, 0);
PostMessage(hWndFolder, WM_KEYUP, VK_F5, 0);
}
I also Googled up this. I don't know if it works.
Code:
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
The same for this one:
Code:
// Refresh desktop
SHGetSpecialFolderLocation
(hwnd, CSIDL_DESKTOPDIRECTORY, &lpil);
SHChangeNotify( SHCNE_ALLEVENTS, SHCNF_IDLIST, lpil, NULL);