Jump to content

How to force update of explorer.exe?


Recommended Posts

Title says it all, I want to modify the registry under Microsoft/Windows/Explorer/Advanced to change some "folder options",

the problem is that explorer won't update to those new settings. For example if I go into folder options and change the option to show all hidden files and folders,

explorer will somehow update itself and then show these folders. But not when I go into the registry and change the key myself.

How do you force explorer to update itself with the new settings?

Thanks

Link to comment
Share on other sites

Title says it all, I want to modify the registry under Microsoft/Windows/Explorer/Advanced to change some "folder options",

the problem is that explorer won't update to those new settings. For example if I go into folder options and change the option to show all hidden files and folders,

explorer will somehow update itself and then show these folders. But not when I go into the registry and change the key myself.

How do you force explorer to update itself with the new settings?

Thanks

Tell me please, what exactly do you change the settings in the registry and how Windows.
Link to comment
Share on other sites

I found this code somewhere on this forum. It was a long while ago and I don't remember who posted it.

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    Opt("WinTitleMatchMode", 4)
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
EndFunc ;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc ;==>_ExplWinGetList
Edited by Dougiefresh
Link to comment
Share on other sites

I found this code somewhere on this forum. It was a long while ago and I don't remember who posted it.

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    Opt("WinTitleMatchMode", 4)
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
EndFunc;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc;==>_ExplWinGetList
This works fine for me. What have you changed in the registry? Edited by Yashied
Link to comment
Share on other sites

Doesn't work for me, crashes AutoIt when I call the update func?

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    Opt("WinTitleMatchMode", 4)
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
EndFunc;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc;==>_ExplWinGetList

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden")
$var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt")

if $var == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "2")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "1")
endif

if $var2 == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "0")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "1")
endif

;quit

Macro is designed to switch the view of hidden files and file extensions on and off with one execution of this prog.

Edited by forumghost
Link to comment
Share on other sites

Doesn't work for me, crashes AutoIt when I call the update func?

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    Opt("WinTitleMatchMode", 4)
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
EndFunc;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc;==>_ExplWinGetList

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden")
$var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt")

if $var == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "2")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "1")
endif

if $var2 == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "0")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "1")
endif

;quit

Macro is designed to switch the view of hidden files and file extensions on and off with one execution of this prog.

This also works fine for me. I work in Windows XP SP2, AutoIt 3.3.0.0.
Link to comment
Share on other sites

I thought I explained this once before but apparently not. This is from a shell extension I wrote. Convert it to AutoIt yourself:

void CSuperHidden::RefreshShell(HWND hWnd) const
{
    // Sending the WM_COMMAND message with ID 0x00007103 to 
    // SHELLDLL_DefView seems to refresh Explorer correctly.  No other 
    // command seems to work.  The logical solution would be to send 
    // the ID of the Refresh menu item, but that doesn't work.  This ID 
    // was found with Spy++ when the context-menu Refresh is selected.
    HWND hRefresh = FindWindowEx(hWnd, NULL, _T("SHELLDLL_DefView"), _T(""));
    if (hRefresh)
        PostMessage(hRefresh, WM_COMMAND, 0x00007103, 0);
}   // RefreshShell()
Link to comment
Share on other sites

CabinetWClass seems wrong, more ExploreWClass?

_Update_Explorer()

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            ConsoleWrite($Hwnd & @crlf)
            $Hwnd = ControlGetHandle($Hwnd, "", "[CLASS:SHELLDLL_DefView; INSTANCE:1]")
            ConsoleWrite($Hwnd & @crlf)
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
EndFunc;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=ExploreWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][1]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc;==>_ExplWinGetList

Edit: Ts, always double check... there was an array in supplied example above... the

$WinListArr[$iW] = $WinList[$iW][0]

has to be

$WinListArr[$iW] = $WinList[$iW][1]

And for the books:

$aResult = DllCall("User32.dll", "hwnd", "FindWindowEx", "hwnd", $Hwnd, "int", 0, "str", "SHELLDLL_DefView", "str", "")
ConsoleWrite($aResult[0] & @crlf)

is the exact translation of the call Valik provided, though

$Hwnd = ControlGetHandle($Hwnd, "", "[CLASS:SHELLDLL_DefView; INSTANCE:1]")
ConsoleWrite($Hwnd & @crlf)

returns exactly the same handle.

Edited by KaFu
Link to comment
Share on other sites

Try this... for me it seems to work :o, searched this one for ages, thanks Valik for pointing in the right direction (in fact pushing my nose into it :D, apologies for my too quick first answer).

_Update_Explorer()

Func _Update_Explorer()
    Local $WinExpListArr, $GetWinState, $Hwnd
    $WinExpListArr = _ExplWinGetList()
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
    ;ConsoleWrite($Hwnd & @crlf)
            $Hwnd = ControlGetHandle($Hwnd, "", "[CLASS:SHELLDLL_DefView; INSTANCE:1]")
    ;ConsoleWrite($Hwnd & @crlf)
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $Hwnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
EndFunc;==>_Update_Explorer

Func _ExplWinGetList()
    Local $WinList, $iW
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0] + 1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
        Return $WinListArr
    Else
        Return ""
    EndIf
EndFunc;==>_ExplWinGetList
Why have you removed the refresh for desktop?
Link to comment
Share on other sites

Why have you removed the refresh for desktop?

Hmmm, good question :D, added again.

Anyone knows what is and where to find CabinetWClass? I can only find ExploreWClass (which seems to work).

Edited by KaFu
Link to comment
Share on other sites

Link to comment
Share on other sites

Sigh, this is why I don't help you people. I end up having to do all the work myself because you can't manage to solve even the most simple of problems. First, Obviously different versions of Windows are using a different class. CabinetWClass is pre-Vista and the other is post-Vista. Or something like that, I don't feel like booting Vista to verify. Second, who gives a fuck, really? Get the right handle to start with and cut out 60% of the code in the process.

Func _Update_Explorer()
    Local $bOld = Opt("WinSearchChildren", True)
    Local $a = WinList("[CLASS:SHELLDLL_DefView]")
    For $i = 0 To UBound($a) - 1
        DllCall("user32.dll", "long", "SendMessage", "hwnd", $a[$i][1], "int", 0x111, "int", 28931, "int", 0)
    Next
    Opt("WinSearchChildren", $bOld)
EndFunc;==>_Update_Explorer
Link to comment
Share on other sites

After a little research I came up with this:

When displaying a standard explorer view, the window has a class of 'CabinetWClass'. When displaying a tree view, it uses 'ExploreWClass'.

So I assume both classes have to be considered.

Edited by KaFu
Link to comment
Share on other sites

still only works sometimes......

it seems as if the explorer takes its loooong time to update itself, anywhere between 2 and 30 seconds (I kept spamming F5 to check), or, well not at all.

(code used atm is

Func _Update_Explorer()
    Local $bOld = Opt("WinSearchChildren", True)
    Local $a = WinList("[CLASS:SHELLDLL_DefView]")
    For $i = 0 To UBound($a) - 1
        DllCall("user32.dll", "long", "SendMessage", "hwnd", $a[$i][1], "int", 0x111, "int", 28931, "int", 0)
    Next
    Opt("WinSearchChildren", $bOld)
EndFunc;==>_Update_Explorer

$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden")
$var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt")

if $var == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "2")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "REG_DWORD", "1")
endif

if $var2 == "1" then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "0")
else
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "REG_DWORD", "1")
endif

Call ("_Update_Explorer()")
;quit
Exit

)

Edited by forumghost
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...