<small id='g9LuH'></small><noframes id='g9LuH'>

      <bdo id='g9LuH'></bdo><ul id='g9LuH'></ul>

    <legend id='g9LuH'><style id='g9LuH'><dir id='g9LuH'><q id='g9LuH'></q></dir></style></legend><tfoot id='g9LuH'></tfoot>

    <i id='g9LuH'><tr id='g9LuH'><dt id='g9LuH'><q id='g9LuH'><span id='g9LuH'><b id='g9LuH'><form id='g9LuH'><ins id='g9LuH'></ins><ul id='g9LuH'></ul><sub id='g9LuH'></sub></form><legend id='g9LuH'></legend><bdo id='g9LuH'><pre id='g9LuH'><center id='g9LuH'></center></pre></bdo></b><th id='g9LuH'></th></span></q></dt></tr></i><div id='g9LuH'><tfoot id='g9LuH'></tfoot><dl id='g9LuH'><fieldset id='g9LuH'></fieldset></dl></div>
    1. 在 Win7 中刷新 Windows 资源管理器

      时间:2023-10-24
    2. <small id='YKxKw'></small><noframes id='YKxKw'>

          <tbody id='YKxKw'></tbody>

          <legend id='YKxKw'><style id='YKxKw'><dir id='YKxKw'><q id='YKxKw'></q></dir></style></legend>
          <i id='YKxKw'><tr id='YKxKw'><dt id='YKxKw'><q id='YKxKw'><span id='YKxKw'><b id='YKxKw'><form id='YKxKw'><ins id='YKxKw'></ins><ul id='YKxKw'></ul><sub id='YKxKw'></sub></form><legend id='YKxKw'></legend><bdo id='YKxKw'><pre id='YKxKw'><center id='YKxKw'></center></pre></bdo></b><th id='YKxKw'></th></span></q></dt></tr></i><div id='YKxKw'><tfoot id='YKxKw'></tfoot><dl id='YKxKw'><fieldset id='YKxKw'></fieldset></dl></div>

          1. <tfoot id='YKxKw'></tfoot>
              <bdo id='YKxKw'></bdo><ul id='YKxKw'></ul>

                本文介绍了在 Win7 中刷新 Windows 资源管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的程序设置 "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced" 值为 "Hidden".但是,我无法刷新资源管理器以考虑此更改.我试过了:

                My program sets "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced" value "Hidden". Hovewer I'm not able to refresh the explorer to take into account this change. I've tried:

                1)

                    SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);` 
                

                2)

                    SHELLSTATE state = new SHELLSTATE(); 
                    state.fShowAllObjects = (uint)1; 
                    SHGetSetSettings(ref state, SSF.SSF_SHOWALLOBJECTS, true); 
                

                3)

                    SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 5000, ref dwResult); 
                

                4)

                    SendMessage(HWND_BROADCAST, WM_COMMAND, 28931 /* Refresh */, 0); 
                

                没有任何作用.所以我该怎么做?如果我自己用 F5 刷新 Explorer,那么它可以工作.但是我想要一些优雅的解决方案,所以它会在任何地方刷新显示,即使在当前打开的 OpenFile/SaveFile 对话框中也是如此.

                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 OpenFile/SaveFile dialogs, which are currently open.

                我正在使用 C# .NET,Win7.

                I'm using C# .NET, Win7.

                正如 Anders 所指出的,有一种使用 COM 刷新资源管理器窗口的简单方法:

                As Anders pointed out, there is a simple way to refresh explorer windows using COM:

                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 < windows.Count; i++)
                    windows.Item(i).Refresh();
                

                所以这部分完成了. 但是我仍然需要刷新 OpenFile/SaveFile 对话框,上面的代码不做那.有人知道如何刷新这些对话框吗?

                So this part is done. Hovewer I still need to refresh the OpenFile/SaveFile dialogs, and the code above doesn't do that. Does anybody know how to refresh those dialogs?

                重要的一点是,如果我在控制面板的文件夹选项中更改显示隐藏文件",系统不会刷新那些 OpenFile/SaveFile 对话框,我必须使用 F5 手动刷新它们.我只是在寻找一种如何使用 C# 刷新所有这些对话框的方法,所以我不再需要按 F5...

                An important point is that if I change the "Show Hidden Files" in Folder Options in Control panel, those OpenFile/SaveFile 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...

                好的,上面代码的新问题 - 它不仅刷新 Windows 资源管理器,还刷新 Internet Explorer...知道如何仅刷新 Windows 资源管理器吗?

                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?

                推荐答案

                我想出了一种方法来检查窗口是否是 Windows 资源管理器窗口,但没有足够的代表来添加评论,所以我想我'd 提交它作为答案来帮助你,因为这个问题帮助了我.

                I figured out a way to check if the windows was a Windows Explorer window, and don't have enough of a rep to add a comment so thought I'd submit it as an answer to help you out because this question helped me out.

                        // 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 < (int)count; i++)
                        {
                            object item = windowsType.InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, windows, new object[] { i });
                            Type itemType = item.GetType();
                
                            // only refresh windows explorers
                            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);
                            }
                        }
                

                这篇关于在 Win7 中刷新 Windows 资源管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何为 Windows 7 编写进度条以在任务栏上进行自我更新? 下一篇:.NET 跳转列表

                相关文章

                  <i id='ig4gv'><tr id='ig4gv'><dt id='ig4gv'><q id='ig4gv'><span id='ig4gv'><b id='ig4gv'><form id='ig4gv'><ins id='ig4gv'></ins><ul id='ig4gv'></ul><sub id='ig4gv'></sub></form><legend id='ig4gv'></legend><bdo id='ig4gv'><pre id='ig4gv'><center id='ig4gv'></center></pre></bdo></b><th id='ig4gv'></th></span></q></dt></tr></i><div id='ig4gv'><tfoot id='ig4gv'></tfoot><dl id='ig4gv'><fieldset id='ig4gv'></fieldset></dl></div>
                  • <bdo id='ig4gv'></bdo><ul id='ig4gv'></ul>
                1. <legend id='ig4gv'><style id='ig4gv'><dir id='ig4gv'><q id='ig4gv'></q></dir></style></legend>

                  <small id='ig4gv'></small><noframes id='ig4gv'>

                2. <tfoot id='ig4gv'></tfoot>