From: Null on
How can I get amount of free space on physical drive (eg. \\.
\PhysicalDrive0 )?
I tried to use GetDiskFreeSpaceEx function but it didn't work.
Thanks for help.
From: Uwe Sieber on
Null wrote:
> How can I get amount of free space on physical drive (eg. \\.
> \PhysicalDrive0 )?
> I tried to use GetDiskFreeSpaceEx function but it didn't work.
> Thanks for help.


\\.\PhysicalDrive is a symbolic link to a DISK device.
Disks just have a certain number of bytes. Usually
disks have one ore more partitions. So, "free space on
physical drive" could be read as "unpartitioned space".
What you can do with disks is to read and write data
and to send IO control request which have DISK in its name,
like IOCTL_DISK_GET_DRIVE_LAYOUT, IOCTL_DISK_GET_PARTITION_INFO,
IOCTL_DISK_GET_DRIVE_GEOMETRY etc.

I think what you mean is the free space on logical drive.
A partition usually is formatted with a file system,
the file system is mounted as a logical drive, a "storage
volume". Storage volumes have "free space" and that is
what GetDiskFreeSpaceEx works with.
It can be called with a path to a folder, like "C:\" or
"\\computer\share\".
A volume name like
"\\?\Volume{519c7010-52ae-11de-83f5-806d6172696f}\" works
too.


Uwe