更新Windows资源管理器中显示的可用空间量 [英] Update free space amount displayed in Windows Explorer

查看:84
本文介绍了更新Windows资源管理器中显示的可用空间量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更新驱动器在Windows资源管理器中显示的可用空间量?

how to update free space amount displayed in Windows Explorer for a drive ?

假定Windows资源管理器已打开,并且已通过编程方式删除了一些文件。
Windows资源管理器将不会刷新以显示新的可用空间。

Suppose Windows Explorer is opened and some files are deleted programmatically. Windows Explorer will not be refreshed to show the new free space available.

因此,我尝试使用 SHChangeNotify 像这样(Delphi代码):

So, I tried to use SHChangeNotify like this (Delphi code) :

ws := 'C:\';
SHChangeNotify (SHCNE_FREESPACE, SHCNF_PATH, PWideChar(ws), nil); 

但它不会更新 Windows资源管理器中报告的值。

but it doesn't update values reported in "Windows Explorer".

请帮助。

推荐答案

如果您使用的是Delphi 7,则 SHCNF_PATH 将映射到ANSI版本 SHCNF_PATHA 。在这种情况下,传递 PWideChar 是错误的。像这样写:

If you are using Delphi 7, then SHCNF_PATH will map to the ANSI version, SHCNF_PATHA. In which case passing PWideChar is wrong. Write it like this:

var
  Drive: string;
....
Drive := 'C:\';
SHChangeNotify(SHCNE_FREESPACE, SHCNF_PATH, PChar(Drive), nil);

或者,如果您喜欢使用Unicode版本,则需要使用 SHCNF_PATHW

Or, if you prefer to use the Unicode version, then you need to use SHCNF_PATHW.

var
  Drive: WideString;
....
Drive := 'C:\';
SHChangeNotify(SHCNE_FREESPACE, SHCNF_PATHW, PWideChar(Drive), nil);

这篇关于更新Windows资源管理器中显示的可用空间量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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