```c
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#define BUFSIZE 1024
BOOL GetDirverInfo(LPSTR szDrive);
void main(void)
{
CHAR szLogicalDriveStrings[BUFSIZE];
PCHAR szDrive;
/*****************************************
* ZeroMemory(szLogicalDriveStrings,BUFSIZE)
* 功能:将指定内存块至零
* 参数:szLogicalDriveStrings,BUFSIZE
* szLogicalDriveStrings 指向一块准备用0来填充的内存区域的开始地址
* BUFSIZE 准备用0来填充的内存区域的大小,按字节来计算
* 返回值:无
******************************************/
ZeroMemory(szLogicalDriveStrings,BUFSIZE);
//获取逻辑驱动器卷名
GetLogicalDriveStrings(BUFSIZE - 1,szLogicalDriveStrings);
szDrive = (PCHAR)szLogicalDriveStrings;
//循环处理每个卷
do
{
if (!GetDirverInfo(szDrive))
{
printf("\nGet Volume Information Error: %d",GetLastError());
}
szDrive += (lstrlen(szDrive)+1);
} while (*szDrive != '\x00');
char ch;
ch = getchar();
}
/*********************************************
* BOOL GetDirverInfo(LPSTR szDrive)
* 功能:获取驱动器的属性
* 参数:LPSTR szDrive
* 指明要获取属性的驱动器的根目录,如C:\
* 返回值 BOOL:表示是否成功
*********************************************/
BOOL GetDirverInfo(LPSTR szDrive)
{
UINT uDiveType;
DWORD dwVolumeSerialNumber;
DWORD dwMaximumComponentLength;
DWORD dwFileSystemFlags;
CHAR szFileSystemNameBuffer[BUFSIZE];
CHAR szDirverName[MAX_PATH];
printf("\n%s\n",szDrive);
/*********************
* UINT WINAPI GetDriveType(LPSTR szDrive);
* 功能:判断一个磁盘驱动器的类型
* 参数:LPSTR szDrive
* 指明要获取属性的驱动器的根目录,如C:\
* 返回值 UINT:表示磁盘类型
**********************/
uDiveType = GetDriveType(szDrive);
switch(uDiveType)
{
case DRIVE_UNKNOWN://未知磁盘类型
printf("The drive type cannot be determined.");
break;
case DRIVE_NO_ROOT_DIR://说明参数是无效
printf("The root path is invalid,for example,no volume is mounted at the path.");
break;
case DRIVE_REMOVABLE://可移动磁盘
printf("The drive is a type that has removable media,for example,\
a floppy drive or removable hard disk.");
break;
case DRIVE_FIXED://固定磁盘
printf("The drive is a type that cannot be removed,for example,a fixed\
hard drive.");
break;
case DRIVE_REMOTE://网络磁盘
printf("The drive is a remote (network) drive");
break;
case DRIVE_CDROM://光驱
printf("The drive is a CD-ROM drive.");
break;
case DRIVE_RAMDISK://RAM
printf("The drive is a RAM disk.");
break;
default:
break;
}
/***********************************
*GetVolumeInformation(szDrive,szDirverName,MAX_PATH,
&dwVolumeSerialNumber,&dwMaximumComponentLength,
&dwFileSystemFlags,szFileSystemNameBuffer,BUFSIZE)
* 功能:获取磁盘驱动器的信息
* 参数:如下
* 返回值:非零即成功
***********************************/
if (!GetVolumeInformation(szDrive,
szDirverName,//卷标(字符串)
MAX_PATH,//szDirveName的长度
&dwVolumeSerialNumber,//用于装载磁盘卷序列号的变量
&dwMaximumComponentLength,//用于装载文件名每一部分的长度
&dwFileSystemFlags,//用于装载一个或多个二进制位标志的变量
szFileSystemNameBuffer,//系统类型
BUFSIZE))
{
return FALSE;
}
if (0!=lstrlen(szDirverName))
{
printf("\nDrive Name is %s\n",szDirverName);
}
printf("\nVolume Serial Number is %u",dwVolumeSerialNumber);
printf("\nMaximun Component Length is %u",dwMaximumComponentLength);
printf("\nSystem Type is %s\n",szFileSystemNameBuffer);
if (dwFileSystemFlags & FILE_SUPPORTS_REPARSE_POINTS)
{
printf("The file system does not support volume mount points.\n");
}
if (dwFileSystemFlags & FILE_VOLUME_QUOTAS)
{
printf("The file system supports disk quotas.\n");
}
if (dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH)
{
printf("The file system supports case-sensitive file names.\n");
}
printf("...\n");
return TRUE;
}
```