title: How can I programmatically refresh Windows Explorer?
body: <p>I have a Windows shell extension that uses <a href="http://msdn.microsoft.com/en-us/library/bb761265(VS.85).aspx" rel="noreferrer">IShellIconOverlayIdentifier</a> interface to display overlay icons on files and folders.  My extension is a little like <a href="http://www.tortoisecvs.org/" rel="noreferrer">TortoiseCVS</a> or <a href="http://tortoisesvn.tigris.org/ExplorerIntegration.html#overlays" rel="noreferrer">TortoiseSVN</a>.</p>
  
  <p>Sometimes I need to make Windows Explorer redraw all it's icons.  To do this, I call <a href="http://msdn.microsoft.com/en-us/library/bb762118(VS.85).aspx" rel="noreferrer">SHChangeNotify</a> like this:</p>
  
  <pre><code>SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL)
  </code></pre>
  
  <p>This refreshes the desktop and right hand pane of any open explorer windows. It doesn't refresh the folder tree on the left hand side of any Explorer windows.</p>
  
  <p>So I tried sending <a href="http://msdn.microsoft.com/en-us/library/ms725497(VS.85).aspx" rel="noreferrer">WM_SETTINGCHANGE</a> like this:</p>
  
  <pre><code>SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0) 
  </code></pre>
  
  <p>on Vista this refreshes the folder tree, but not the right hand pane.</p>
  
  <p>The combination of <code>SHChangeNotify()</code> followed by <code>WM_SETTINGCHANGE</code> seems to work quite well on Vista.  But I still can't refresh the folder tree on XP if it is displayed. </p>
  
  <p>Does anyone have any ideas how to do this better?  </p>
  
  <p>Is there a better solution for XP?</p>
  
  <p>Sending <code>SHCNE_ASSOCCHANGED</code> is a bit like clubbing Explorer over the head.  It causes the whole desktop to refresh quite violently and casues any open Explorer windows to loose there scroll position.  Is there anything that's a bit less violent?</p>