Volume Information
A C program that queries a drive's volume name, file system, and capability flags with GetVolumeInformation.
One call - GetVolumeInformation - answers most of the "what is this drive?" questions: the volume label, the file system name (NTFS, FAT32...), the serial number, the maximum component length, and a bitmask of filesystem capabilities. This snippet prints the friendly bits and then decodes each flag into plain English: case preservation, case sensitivity, Unicode filenames, persistent ACLs, file compression support, and whether the volume itself is compressed. Useful in installers checking for NTFS before using features like alternate data streams or hard links.
#include <Windows.H>
#include <WindowsX.H>
#include <Stdio.H>
#include <Stdlib.H>
int main()
{
char VolumeNameBuffer[1024];
DWORD VolumeNameSize = sizeof(VolumeNameBuffer);
DWORD VolumeSerialNumber;
DWORD MaximumComponentLength;
DWORD FileSystemFlags;
char FileSystemNameBuffer[1024];
DWORD FileSystemNameSize = sizeof(FileSystemNameBuffer);
GetVolumeInformation(
"C:\\\\",
VolumeNameBuffer,
VolumeNameSize,
&VolumeSerialNumber,
&MaximumComponentLength,
&FileSystemFlags,
FileSystemNameBuffer,
FileSystemNameSize
);
char Temp[1024];
sprintf(Temp,"\t Volume Name: %s\r\n",VolumeNameBuffer);
printf(Temp);
sprintf(Temp,"\t File System: %s\r\n",FileSystemNameBuffer);
printf(Temp);
sprintf(Temp,"\t Max File Name Length: %d\r\n",MaximumComponentLength);
printf(Temp);
printf("\t Volume Flags:\r\n");
if(FileSystemFlags & FS_CASE_IS_PRESERVED)
printf("\t\t File Case Is Preserved.\r\n");
if(FileSystemFlags & FS_CASE_SENSITIVE)
printf("\t\t Supports Case Sensitive Names.\r\n");
if(FileSystemFlags & FS_UNICODE_STORED_ON_DISK)
printf("\t\t Supports Unicode In Filenames.\r\n");
if(FileSystemFlags & FS_PERSISTENT_ACLS)
printf("\t\t Security Is Preserved And Enforced.\r\n");
if(FileSystemFlags & FS_FILE_COMPRESSION)
printf("\t\t Supports File-Based Compression.\r\n");
if(FileSystemFlags & FS_VOL_IS_COMPRESSED)
printf("\t\t Volume Is Compressed.\r\n");
return 0;
}
The commented-out lines show how to also print the raw volume label, file system string, and serial number. For free/total space on the same drive, follow up with GetDiskFreeSpaceEx - together the two calls cover nearly every drive-inspection need.