1

In order to update some desktop icons, I want to stop & restart Windows Explorer (WE), but without losing the currently open folders. To accomplish this, I either need to save the currently open folders and then restore them on my own or find out where WE keeps the list and have it restore them for me. Any thought or comments will be most appreciated.

Stacker
  • 27
  • 3
  • I don't think it keeps a list. There is one window per folder open. – drescherjm Dec 30 '17 at 19:01
  • There is an option to restore previous WE windows after a reboot...Perhaps it stores the folders in the registry – Grantly Dec 30 '17 at 19:02
  • 2
    We need some more information about what you are trying to update and why. There might a be API you should be calling instead of using a big hammer... – Anders Dec 30 '17 at 19:13
  • Basically I want to simulate multi-desktops because i am not happy with any of the ones I have tried. As part of this I have found the sometimes WE wants to update the icons on the desktop on its own which makes it hard to know when it is done, which is why I want it 'disabled' until I have the new layout set. – Stacker Dec 30 '17 at 20:47
  • Windows supports virtual desktops starting with Windows 10. Unless I misunderstood what you meant by *"multi-desktops"*, you should check out the built-in feature instead of rolling your own (which is typically a fairly non-trivial task). – IInspectable Dec 30 '17 at 21:09
  • @ IInspectable. I have looked at the built-in 'support', but as far as I have been able to figure out, each desktop cannot be 'customized' with its own background images nor with a separate set of icons, specific to a given set of tasks. If these features are available and I just have not found them, I'd be most happy to find out more about them. Otherwise, all these 'clones' are not very helpful, IMO, when coming back to a screen to help carry on where one left off. – Stacker Dec 30 '17 at 21:33

1 Answers1

1

If you have changed registered file-type icons you can just call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);.

You can use IShellWindows to get information about open Explorer windows but I would recommend that you try using Restart Manager (example application) instead.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Thank you for the example application, including source. As is, it won't do what I need because if I run RestartViaManager "C:\Windows\Explorer.exe" from a command line, it does restart WE, but any open folders will not be opened after or remain open during the restart. – Stacker Dec 30 '17 at 20:51
  • BTW, `SHChangeNotify()` when called as above does not only refresh file-type icons. It clears the whole icon cache, so this will also refresh icons of executable files and so on. @Stacker Use `IShellWindows` to get all explorer windows, save their current folder paths and positions. After restart, you can restore the windows. All you need is on the linked page. – zett42 Dec 30 '17 at 22:38
  • @zett42 SHChangeNotify does not clear the whole icon cache. It does however force reloading of a lot of icons. – Anders Dec 31 '17 at 00:35
  • Let's agree that it does a lot more than the documentation implies. Raymond Chen refers to it as ["to demolish the house and rebuild it"](https://blogs.msdn.microsoft.com/oldnewthing/20150903-00/?p=91671/). – zett42 Dec 31 '17 at 12:17
  • @zett42 - after struggling a bit with finding enough details to get what I needed, I found your comment/solution at: https://stackoverflow.com/questions/43815932/how-to-get-the-path-of-an-active-file-explorer-window-in-c-winapi and it gets me what I think/thought I need. My next job will be to figure out how to hide and show any explorer windows, because that would make it even easier - no need to delete and restore, simply hide & show. Your solution does list windows which are hidden, which is what got me thinking :-) – Stacker Jan 01 '18 at 02:14