how to update free space amount displayed in Windows Explorer for a drive ?
Suppose Windows Explorer is opened and some files are deleted programmatically. Windows Explorer will not be refreshed to show the new free space available.
So, I tried to use SHChangeNotify
like this (Delphi code) :
ws := 'C:\';
SHChangeNotify (SHCNE_FREESPACE, SHCNF_PATH, PWideChar(ws), nil);
but it doesn't update values reported in "Windows Explorer".
Please help.
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);
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);
来源:https://stackoverflow.com/questions/13929923/update-free-space-amount-displayed-in-windows-explorer