Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh Windows Explorer in Win7
    text
    copied!<p>My program sets <code>"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"</code> value <code>"Hidden"</code>. Hovewer I'm not able to refresh the explorer to take into account this change. I've tried:</p> <p>1) </p> <pre><code> SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);` </code></pre> <p>2)</p> <pre><code> SHELLSTATE state = new SHELLSTATE(); state.fShowAllObjects = (uint)1; SHGetSetSettings(ref state, SSF.SSF_SHOWALLOBJECTS, true); </code></pre> <p>3) </p> <pre><code> SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 5000, ref dwResult); </code></pre> <p>4) </p> <pre><code> SendMessage(HWND_BROADCAST, WM_COMMAND, 28931 /* Refresh */, 0); </code></pre> <p>Nothing works. So what should I do? If I refresh Explorer myself with F5, then it works. Hovewer I would like some elegant solution, so it would refresh the display everywhere, even in <code>OpenFile</code>/<code>SaveFile</code> dialogs, which are currently open.</p> <p>I'm using C# .NET, Win7.</p> <h2>Status Update #1</h2> <p>As <code>Anders</code> pointed out, there is a simple way to refresh explorer windows using COM:</p> <pre><code>Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000"); Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true); dynamic shellApplication = Activator.CreateInstance(shellApplicationType); dynamic windows = shellApplication.Windows(); for (int i = 0; i &lt; windows.Count; i++) windows.Item(i).Refresh(); </code></pre> <p><del>So this part is done.</del> Hovewer I still need to refresh the <code>OpenFile</code>/<code>SaveFile</code> dialogs, and the code above doesn't do that. Does anybody know how to refresh those dialogs?</p> <p>An important point is that if I change the "Show Hidden Files" in Folder Options in Control panel, those <code>OpenFile</code>/<code>SaveFile</code> dialogs are not refreshed by the system, I must refresh them manually using F5. I'm just looking for a method how to refresh all those dialogs using C#, so I don't need to press F5 anymore...</p> <h2>Status Update #2</h2> <p>Ok, so new problem with the code above - it refresh not only windows explorers, but also internet explorers... Any idea how to refresh windows explorers ONLY?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload