码迷,mamicode.com
首页 > 其他好文 > 详细

获得驱动器属性

时间:2015-03-16 10:59:21      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>

BOOL GetDriverInfo(LPSTR szDrive)//获得驱动器类型
{
    printf("%s\n",szDrive);
    UINT uDriveType;
    uDriveType = GetDriveType(szDrive);
    switch(uDriveType)
    {
    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 removalbe media, for example, a floppy drive or removable hard disk.");
        break;
    case DRIVE_FIXED:
        printf("The drive is a type taht cannot be removed, for exalmpl, 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-Rome drive");
        break;
    case DRIVE_RAMDISK:
        printf("The drive is a RAM disk.");
        break;
    default:
        break;
    }
    CHAR szDriveName[MAX_PATH];
    DWORD dwVolumeSerialNumber;
    DWORD dwMaximumComponentLength;
    DWORD dwFileSystemFlags;
    CHAR szFileSystemNameBuffer[MAX_PATH];
    if(!GetVolumeInformation(
        szDrive,
        szDriveName,
        MAX_PATH,
        &dwVolumeSerialNumber,
        &dwMaximumComponentLength,
        &dwFileSystemFlags,
        szFileSystemNameBuffer,
        MAX_PATH
        ))
    {
        return FALSE;
    }

    if(0 != lstrlen(szDriveName))
    {
        printf("\nDrive Name is %s\n",szDriveName);
    }
    printf("\nVolume Serial Number is %u",dwVolumeSerialNumber);
    printf("\nMaximum Component Length is %u", dwMaximumComponentLength);
    printf("\nSystem Type is %s", szFileSystemNameBuffer);
    if(dwFileSystemFlags & FILE_VOLUME_QUOTAS)
    {
        printf("\nThe file system supports disk quotes.\n");

    }
    if(dwFileSystemFlags & FILE_SUPPORTS_ENCRYPTION)
    {
        printf("\nThe file system supports encryption.");
    }

    printf("\n...\n");
    return TRUE;

}
int main()
{
    GetDriverInfo(TEXT("c:\\"));
    system("pause");
    return 0;
}

 

获得驱动器属性

标签:

原文地址:http://www.cnblogs.com/gongyan/p/4341239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!