GetVolumeStatistics
Returns information about a volume
#include <nwdir.h>
int GetVolumeStatistics (
WORD fileServerID,
BYTE volumeNumber,
int structSize,
VOLUME_INFO *returnedVolumeStatistics);
On remote calls, in the structure returned for returnedVolumeStatistics, GetVolumeStatistics returns -1 in the systemElapsedTime field and -1 in the startingBlock field working as designed.
If structSize is less than the size of VOLUME_INFO, then only the first structSize bytes of VOLUME_INFO are returned.
The following equations explain how to calculate available disk space in bytes:
The VOLUME_INFO structure, pointed to by the returnedVolumeStatistics parameter, has the following format:
long systemElapsedTime;
BYTE volumeNumber;
BYTE logicalDriveNumber;
WORD sectorsPerBlock;
short startingBlock;
LONG totalBlocks;
LONG availableBlocks;
LONG totalDirectorySlots;
LONG availableDirecotrySlots;
BYTE isHashing;
BYTE isRemovable;
BYTE isMounted;
char volumeName[17];
LONG purgableBlocks;
LONG notyetPurgableBlocks;
The isRemovable field always returns true.
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <fcntl.h>
#include <nwshare.h>
#include <nwbitops.h>
#include <nwfile.h>
#include <nwdir.h>
#include <nwtts.h>
#include <nwbindry.h>
#include <time.h>
main()
{
int rc;
VOLUME_INFO vs;
char svn[10];
int vn;
printf("volume number: ");
gets(svn);
vn = atoi(svn);
rc = GetVolumeStatistics(0,vn,sizeof (vs),&vs);
if(rc)
{
printf("rc = %d\r\n",rc);
printf("errno = %d\r\n",errno);
printf("%s\r\n",strerror(errno));
}
else
{
printf("systemElapsedTime = %d\r\n",vs.systemElapsedTime);
printf("volumeNumber = %d\r\n",vs.volumeNumber);
printf("logicalDriveNumber = %d\r\n",vs.logicalDriveNumber);
printf("sectorsPerBlock = %d\r\n",vs.sectorsPerBlock);
printf("startingBlock = %d\r\n",vs.startingBlock);
printf("totalBlocks = %d\r\n",vs.totalBlocks);
printf("availableBlocks = %d\r\n",vs.availableBlocks);
printf("totalDirectorySlots = %d\r\n",
vs.totalDirectorySlots);
printf("availableDirectorySlots = %d\r\n",
vs.availableDirectorySlots);
printf("isHashing = %d\r\n",vs.isHashing);
printf("isRemovable = %d\r\n",vs.isRemovable);
printf("isMounted = %d\r\n",vs.isMounted);
printf("volumeName = %s\r\n",vs.volumeName);
}
}