如何刷新 Windows 资源管理器
可以更改网络卷的名称。
我将名称更改为Spinal Disk
要更改网络名称,我
- 在注册表中写入新名称。
- 使用 DefineDosDeviceW 等函数附加我的网络卷。在这个时间点,Windows资源管理器在我的猜测中读取了注册表。
- SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, 根, NULL); // 可以肯定的是。
- SendMessageTimeout(HWND_BROADCAST, WM_DEVICECHANGE, 消息, (LPARAM)(&dbv), - SMTO_ABORTIFHUNG, 200, &dwResult); // 再次确认!
它可以工作,但有时即使我使用 SHChangeNotify 和 WM_DEVICECHANGE 也无法确定。有时,新名称不会应用在 Windows 资源管理器中。
但如果我终止资源管理器并重新执行,则会应用该名称。
我发现一个Windows资源管理器刷新的界面。(语法正确吗?抱歉,我不能很好地表达这句话。)
有合适的功能吗?资源管理器应该重新读取注册表并刷新。
A network volume's name can be changed.
I changed the name to Spinal Disk
To change a network name, I do
- Write new name in Registry.
- Attach my network volume using functions like DefineDosDeviceW. In this timing, Windows explorer read registry in my guessing.
- SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); // To be sure.
- SendMessageTimeout(HWND_BROADCAST, WM_DEVICECHANGE, message, (LPARAM)(&dbv), - SMTO_ABORTIFHUNG, 200, &dwResult); // To be sure again!
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,资源管理器根本无法在每次被告知时刷新。因为太多应用程序表现不佳并且总是将 SHChangeNotify() 与
SHCNE_ALLEVENTS
一起使用。想象一下,如果浏览器真的每次收到该通知时都会刷新所有内容(是的,有时每秒几次!)。这就是为什么它有时不起作用。但你可以通过以下方法“欺骗”探索者:
从下往上发送针对多个路径的通知。通常,首先发送例如
N:\folder
的通知,然后让N:\
真正刷新N:\
就足够了。您应该首先发送
WM_DEVICECHANGE
消息,然后才调用SHChangeNotify()。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.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 forN:\
to really refreshN:\
.And you should send the
WM_DEVICECHANGE
message first, and only then call SHChangeNotify().使用 SHChangeNotify()。实际上不确定在这种特殊情况下您会使用哪个 wEventId。从 SHCNE_ALLEVENTS 开始。
Use SHChangeNotify(). Not actually sure which wEventId you'd use in this particular case. Start with SHCNE_ALLEVENTS.