Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to refresh/reload Desktop
    primarykey
    data
    text
    <p>I have a WPF C# project in which I'm implementing settings for Windows folder options. One of them is "Single-click to open an item" (instead of double-click). When I change the registry keys for that matter, I need to refresh Windows Explorer which I found a solution for. But desktop doesn't refresh, and even refreshing it manually doesn't apply the changes. I've used IActiveDesktop::ApplyChanges Method but didn't work (or maybe I made a mistake). I've also used this code snippet, but it still doesn't apply the changes I've made:</p> <pre><code>SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero); </code></pre> <p>And here is the full code snippet that I used for refreshing Win Explorer(witch is from this site):</p> <pre><code>[System.Runtime.InteropServices.DllImport("Shell32.dll")] private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2); public static void RefreshWindowsExplorer() { // Refresh the desktop SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero); // Refresh any open explorer windows // based on http://stackoverflow.com/questions/2488727/refresh-windows-explorer-in-win7 Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000"); Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true); object shellApplication = Activator.CreateInstance(shellApplicationType); object windows = shellApplicationType.InvokeMember("Windows", System.Reflection.BindingFlags.InvokeMethod, null, shellApplication, new object[] { }); Type windowsType = windows.GetType(); object count = windowsType.InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, null, windows, null); for (int i = 0; i &lt; (int)count; i++) { object item = windowsType.InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, windows, new object[] { i }); Type itemType = item.GetType(); // Only refresh Windows Explorer, without checking for the name this could refresh open IE windows string itemName = (string)itemType.InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, item, null); if (itemName == "Windows Explorer") { itemType.InvokeMember("Refresh", System.Reflection.BindingFlags.InvokeMethod, null, item, null); } } } </code></pre> <p>That works for Windows Explorer but not the desktop (which is odd since desktop depends on explorer too). So how should I reload the desktop so that my changes take effect?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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