GetVolumeInformation
Returns information about a volume
#include <nwdir.h>
int GetVolumeInformation (
WORD fileServerID,
BYTE volumeNumber,
int structSize,
VOLUME_STATS *volumeStatistics);
If structSize is less than the size of VOLUME_STATS, then only the first structSize bytes of VOLUME_STATS are returned.
The VOLUME_STATS structure, pointed to by the volumeStatistics parameter, has the following format:
long systemElapsedTime;
BYTE volumeNumber;
BYTE logicalDriveNumber;
WORD sectorsPerBlock;
long startingBlock;
WORD totalBlocks;
WORD availableBlocks;
WORD totalDirectorySlots;
WORD availableDirectorySlots;
WORD maxDirectorySlotsUsed;
BYTE isHashing;
BYTE isRemovable;
BYTE isMounted;
char volumeName[17];
LONG purgableBlocks;
LONG notYetPurgableBlocks;
IMPORTANT:With large volumes, the number of blocks to be returned in totalBlocks or availableBlocks may be greater than 64K, resulting in inaccurate field values because of limited field size. In such instances, use GetVolumeStatistics instead of this function.
The isRemovable field always returns true.
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <fcntl.h>
#include <nwshare.h>
#include <nwdir.h>
#include <nwbitops.h>
#include <nwtts.h>
#include <nwbindry.h>
#include <time.h>
main()
{
int rc;
VOLUME_STATS vs;
char
svn[10];
int vn;
printf("volume number: ");
gets(svn);
vn = atoi(svn);
rc = GetVolumeInformation(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("maxDirectorySlotsUsed = %d\r\n",
vs.maxDirectorySlotsUsed);
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);
}
}