Page 1 of 1

Refresh Windows Explorer (WinXP)

Posted: 27 Mar 2016, 12:20
by Zvonko
It is not difficult to find hints how to refresh Windows Explorer programmatically (e.g. to activate changes made in Registry):
Send {F5},
PostMessage, 0x111 ...

However, these methods seems to fail in Windows XP: After changing the sincleclick/doubleclick setting ('Single-click to open item' ...) via Registry, F5 can be used in Win8.1 and Win10, but not in Win XP; here the change becomes effective only via Refresh from context menu.

So this is my question:
I know that InvokeVerb can be used to invoke a verb from context menu, or simply sending keystrokes to open context menu and select Refresh. However, I need a solution which is independent of the Windows language. (Also I am not sure that Refresh is the fourth item in the context menu in all Windows languages.)
So I would like to invoke directly, not via context menu, the same action which is done via Refresh.

Any idea?

Code: Select all

;Not working in WinXP:        
ControlSend, %ExplControl%, {F5}, ahk_id %curId%
PostMessage, 0x111, 41504,, %ExplControl%, ahk_id %curId%
PostMessage, 0x111, 28931,, %ExplControl%, ahk_id %curId%   ; ahk_class CabinetWClass
DllCall( "Shell32\SHChangeNotify", UInt,0x08000000, UInt,0, Int,0, Int,0 ) ; SHCNE_ASSOCCHANGED
PostMessage, 0x1A,,, %ExplControl%, ahk_id %curId% ; ahk_class Progman
Run RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
SendMessage, 0x1A,0, 10000,SysListView321, ahk_id %curId% ;ahk_class %ExplClass%
SendMessage, 0x0B, 0, 1,SysListView321, ahk_id %curId% ;ahk_class %ExplClass%

Re: Refresh Windows Explorer (WinXP)

Posted: 27 Mar 2016, 18:38
by qwerty12
I know you already said you tried SHChangeNotify, but it does actually work here for me at least to toggle between single and double-click with an instant refresh of all Explorer windows (including the Desktop) on an XP Pro virtual machine:

Code: Select all

VarSetCapacity(SHELLSTATE, 32, 0)
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", 0x00000080, "Int", false) ;SSF_DOUBLECLICKINWEBVIEW
;NumPut(32 * !(NumGet(SHELLSTATE) >> 5), &SHELLSTATE,, "Int") ; Warning: Something tells me this isn't the proper way to do this...
NumPut(NumGet(SHELLSTATE) ^ (1 << 5), SHELLSTATE,, "Int")
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", 0x00000080, "Int", true) ; SSF_DOUBLECLICKINWEBVIEW
DllCall("Shell32\SHChangeNotify", "Int", 0x8000000, "UInt", 0, "Ptr", 0, "Ptr", 0) ; SHCNE_ASSOCCHANGED

Re: Refresh Windows Explorer (WinXP)

Posted: 28 Mar 2016, 08:17
by Zvonko
Thank you very much, querty12!!!

Your answer does not answer my explicite question (to which I would still like to have an answer), but it solves my specific problem:
I used another method to change the SC/DC setting. With your method there is no problem with refresh, so I will use this method.

Your NumPut line switches the setting (from SC to DC Mode or from DC to SC Mode).
To force the DC Mode, NumPut(32, &SHELLSTATE,, "Int") can be used,
to force the SC Mode, NumPut(0, &SHELLSTATE,, "Int") can be used.