Update free space displayed in Windows Explorer

How to update the amount of free space displayed in Windows Explorer for a disk?

Suppose Windows Explorer is open and some files are deleted programmatically. Windows Explorer will not be updated to show new free space.

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

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

but it does not update the values ​​specified in Windows Explorer.

Please, help.

+1
source share
1 answer

If you are using Delphi 7, then the version of ANSI, SHCNF_PATHA will be displayed on SHCNF_PATHA . In this case, the PWideChar transfer is incorrect. 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, you need to use SHCNF_PATHW .

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

All Articles