How to refresh folder
-
If any folder is open in window explorer then how to refresh its contents. Say c:/xyz is open, it contains some files and folders, i want to progratically refresh the children.
Are you working on mfc?? if yes then, i think you can just redraw whatever it is that you want on the screen.
Every new day is another chance to change your life.
-
If any folder is open in window explorer then how to refresh its contents. Say c:/xyz is open, it contains some files and folders, i want to progratically refresh the children.
How exactly do you mean "programmatically"? With an external program or an explorer addin?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
If any folder is open in window explorer then how to refresh its contents. Say c:/xyz is open, it contains some files and folders, i want to progratically refresh the children.
Here you go.
// Call for each explorer window
HWND hExplorer = FindWindowEx(GetDesktopWindow(), NULL, L"ExploreWClass", NULL); while(hExplorer != NULL) { EnumChildWindows(hExplorer, RefreshFolderSelectionCB, (LPARAM)&packet); hExplorer = FindWindowEx(GetDesktopWindow(), hExplorer, L"ExploreWClass", NULL); }
...
...
...BOOL CALLBACK RefreshFolderSelectionCB(HWND hWnd, LPARAM lParam)
{
WCHAR sBuffer[MAX_PATH] = {0};::GetClassName(hWnd, sBuffer, MAX\_PATH); if (wcscmp(L"SysTreeView32", sBuffer) == 0) { RefreshFolderSelectionPacket\* pPacket = (RefreshFolderSelectionPacket\*)lParam; // Refreshes the tree nodes that match the contained full paths, and all their open descendants // Paths are updated by calling UpdateItem (below) // Cache is used across explorer instances to ensure no path is updated twice. RefreshSelection(pPacket); } return TRUE;
}
...
...
static void UpdateItem(IShellFolder* pDesktop, const std::wstring& rsFullPath)
{
PIDLIST_RELATIVE pIDL;if (SUCCEEDED(pDesktop->ParseDisplayName(NULL, NULL, (LPWSTR)rsFullPath.c\_str(), NULL, &pIDL, NULL))) { SHChangeNotify(SHCNE\_UPDATEITEM, SHCNF\_IDLIST|SHCNF\_NOTIFYRECURSIVE|SHCNF\_FLUSH, pIDL, NULL); ILFree(pIDL); }
}
-
Here you go.
// Call for each explorer window
HWND hExplorer = FindWindowEx(GetDesktopWindow(), NULL, L"ExploreWClass", NULL); while(hExplorer != NULL) { EnumChildWindows(hExplorer, RefreshFolderSelectionCB, (LPARAM)&packet); hExplorer = FindWindowEx(GetDesktopWindow(), hExplorer, L"ExploreWClass", NULL); }
...
...
...BOOL CALLBACK RefreshFolderSelectionCB(HWND hWnd, LPARAM lParam)
{
WCHAR sBuffer[MAX_PATH] = {0};::GetClassName(hWnd, sBuffer, MAX\_PATH); if (wcscmp(L"SysTreeView32", sBuffer) == 0) { RefreshFolderSelectionPacket\* pPacket = (RefreshFolderSelectionPacket\*)lParam; // Refreshes the tree nodes that match the contained full paths, and all their open descendants // Paths are updated by calling UpdateItem (below) // Cache is used across explorer instances to ensure no path is updated twice. RefreshSelection(pPacket); } return TRUE;
}
...
...
static void UpdateItem(IShellFolder* pDesktop, const std::wstring& rsFullPath)
{
PIDLIST_RELATIVE pIDL;if (SUCCEEDED(pDesktop->ParseDisplayName(NULL, NULL, (LPWSTR)rsFullPath.c\_str(), NULL, &pIDL, NULL))) { SHChangeNotify(SHCNE\_UPDATEITEM, SHCNF\_IDLIST|SHCNF\_NOTIFYRECURSIVE|SHCNF\_FLUSH, pIDL, NULL); ILFree(pIDL); }
}
http://social.msdn.microsoft.com/Forums/en/windowssdk/thread/cc4a702f-1b2f-4d19-bf68-c88967544172[^] Where do
RefreshFolderSelectionPacket
andRefreshSelection()
come from?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
http://social.msdn.microsoft.com/Forums/en/windowssdk/thread/cc4a702f-1b2f-4d19-bf68-c88967544172[^] Where do
RefreshFolderSelectionPacket
andRefreshSelection()
come from?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
How exactly do you mean "programmatically"? With an external program or an explorer addin?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Here you go.
// Call for each explorer window
HWND hExplorer = FindWindowEx(GetDesktopWindow(), NULL, L"ExploreWClass", NULL); while(hExplorer != NULL) { EnumChildWindows(hExplorer, RefreshFolderSelectionCB, (LPARAM)&packet); hExplorer = FindWindowEx(GetDesktopWindow(), hExplorer, L"ExploreWClass", NULL); }
...
...
...BOOL CALLBACK RefreshFolderSelectionCB(HWND hWnd, LPARAM lParam)
{
WCHAR sBuffer[MAX_PATH] = {0};::GetClassName(hWnd, sBuffer, MAX\_PATH); if (wcscmp(L"SysTreeView32", sBuffer) == 0) { RefreshFolderSelectionPacket\* pPacket = (RefreshFolderSelectionPacket\*)lParam; // Refreshes the tree nodes that match the contained full paths, and all their open descendants // Paths are updated by calling UpdateItem (below) // Cache is used across explorer instances to ensure no path is updated twice. RefreshSelection(pPacket); } return TRUE;
}
...
...
static void UpdateItem(IShellFolder* pDesktop, const std::wstring& rsFullPath)
{
PIDLIST_RELATIVE pIDL;if (SUCCEEDED(pDesktop->ParseDisplayName(NULL, NULL, (LPWSTR)rsFullPath.c\_str(), NULL, &pIDL, NULL))) { SHChangeNotify(SHCNE\_UPDATEITEM, SHCNF\_IDLIST|SHCNF\_NOTIFYRECURSIVE|SHCNF\_FLUSH, pIDL, NULL); ILFree(pIDL); }
}