如何刷新 Windows 资源管理器 [英] How to refresh Windows Explorer

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

问题描述

可以更改网络卷的名称.
我把名字改成了Spinal Disk

A network volume's name can be changed.
I changed the name to Spinal Disk

要更改网络名称,我会这样做

To change a network name, I do

  • 在注册表中写入新名称.
  • 使用 DefineDosDeviceW 等函数附加我的网络卷.在这个时间里,Windows 资源管理器在我的猜测中读取了注册表.
  • SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);//可以肯定.
  • SendMessageTimeout(HWND_BROADCAST, WM_DEVICECHANGE, message, (LPARAM)(&dbv), - SMTO_ABORTIFHUNG, 200, &dwResult);//再次确定!

它可以工作,但有时即使我使用 SHChangeNotify 和 WM_DEVICECHANGE 也不能工作.有时,新名称不会在 Windows 资源管理器中应用.
但是,如果我终止 Explorer 并重新执行,则会应用该名称.

It works, but sometimes doesn't work even though I use SHChangeNotify and WM_DEVICECHANGE to be sure. Sometimes, the new name is not applied in Windows Explorer.
But if I terminate Explorer and re-execute, the name applied.

我正在寻找一个刷新了 Windows Explorer 的界面.(语法是否正确?抱歉,我无法很好地表达这句话.)
有合适的功能吗?Explorer 应重新读取注册表并进行刷新.

I'm finding an interface having Windows Explorer refreshed.(Is it correct syntax? Sorry, I can't express this sentence well.)
Is there a proper function? Explorer should re-read registry and be refreshed.

推荐答案

不幸的是,Explorer 无法在每次被告知时都刷新.因为太多的应用程序表现不佳,总是使用 SHChangeNotify()SHCNE_ALLEVENTS.想象一下,如果浏览器真的每次收到通知时都会刷新所有内容(是的,有时每秒几次!).这就是为什么它有时不起作用的原因.

Unfortunately, Explorer simply can't refresh every time it is told so. Because way too many apps behave badly and always use SHChangeNotify() with SHCNE_ALLEVENTS. Imagine if the explorer would really always refreshed everything every time it receives that notification (yes, sometimes several times per second!). That's why it sometimes doesn't work.

但这里是你可以欺骗"探险家的方法:
从下往上发送多个路径的通知.通常,首先发送通知就足够了,例如N:folder 然后为 N: 真正刷新 N:.

But here's how you can 'trick' the explorer:
Send a notification for more than one path, from the bottom up. Usually it's enough to first send a notification for e.g. N:folder and then for N: to really refresh N:.

您应该首先发送WM_DEVICECHANGE消息,然后才调用SHChangeNotify().

And you should send the WM_DEVICECHANGE message first, and only then call SHChangeNotify().

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆