I’m trying to use the WinAPI function GetDiskSpaceInformationA
(or its Unicode counterpart GetDiskSpaceInformationW
) to retrieve disk space information for USB volumes on Windows. However, I’ve encountered an issue where these functions seem to work for internal disks (e.g., C:
), but fail with the error ERROR_INVALID_PARAMETER
when I try to use them on USB volumes.
I’ve tried various ways to specify the USB volume path, including:
- Drive letter (e.g.,
D:
) - Drive letter without trailing backslash (e.g.,
D:
) - Volume GUID path (e.g.,
\?Volume{GUID}
) - Volume GUID path without trailing backslash (e.g.,
\?Volume{GUID}
)
But none of these approaches have succeeded. The functions only seem to work for internal disks, not USB volumes.
Is this a limitation of these functions, or am I doing something wrong? Is there a different API function I should be using to retrieve disk space information for USB volumes on Windows?
Any guidance or insights would be appreciated.
user3144255 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.