zoukankan      html  css  js  c++  java
  • GetLogicalDriveStringS获取驱动器根路径 流沙

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

    // 预定义
    #define BUFSIZE 1024

    //函数申明
    BOOL GetDirverInfo(LPSTR szDrive);


    void main(void)
    {
    CHAR szLogicalDriveStrings[BUFSIZE];
    PCHAR szDrive;用来指向字符数组

    //将上面申请的CHar数组用O填充
    ZeroMemory(szLogicalDriveStrings,BUFSIZE);
    //获取逻辑驱动器卷标名  写入数组
    GetLogicalDriveStrings(BUFSIZE-1,szLogicalDriveStrings);
    //指向字符数组
    szDrive=(PCHAR)szLogicalDriveStrings;

    //循环每个卷
    do
    {
    if(!GetDirverInfo(szDrive))
    {
    printf("\n 获取错误:%d",GetLastError());
    }
    szDrive +=(lstrlen(szDrive)+1);
    }
    while(*szDrive!='\x00');

    printf("\n",szDrive);
    }


    BOOL GetDirverInfo(LPSTR szDrive)
    {
    UINT uDriveType;
    DWORD dwVolumeSerialNumber;
    DWORD dwMaximumComponentLength;
    DWORD dwFileSystemFlags;
    CHAR szFileSystemNameBuffer[BUFSIZE];
    CHAR szDirveName[MAX_PATH];

    printf("\n%s\n",szDrive);
    uDriveType = GetDriveType(szDrive);//TCHAR的指针类型
    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 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:
    printf("the drive is a RAM disk");
    break;
    default:
    break;

    }
    if(!GetVolumeInformation(//读取文件系统信息
    szDrive,
    szDirveName,
    MAX_PATH,
    &dwVolumeSerialNumber,
    &dwMaximumComponentLength,
    &dwFileSystemFlags,
    szFileSystemNameBuffer,
    BUFSIZE
    ))
    {
    return FALSE;
    }
    if(0!=lstrlen(szDirveName))
    {
    printf("\nDrive name is %s\n",szDirveName);
    }
    printf("\nVolume serial Number is %u",dwVolumeSerialNumber);
    printf("\nMaximum Component Length is %u",dwMaximumComponentLength);
    printf("\nsystem type is %s\n",szFileSystemNameBuffer);

    if (dwFileSystemFlags & FILE_VOLUME_QUOTAS)
    {
    printf("the file system supports disk quotas");

    }
    if (dwFileSystemFlags & FILE_CASE_SENSITIVE_SEARCH)
    {
    printf("the file system supports case-sensitive file names");
    }
    return TRUE;
    }

  • 相关阅读:
    SuperSocket 1.4系列文档(16) 在SuperSocket中启用传输层加密(TLS/SSL)
    SuperSocket 1.4系列文档(10) SuperSocket中的日志功能
    UIPageControl实现自定义按钮
    ios 某些代码网址,app打包成ipa
    笔记隐藏状态栏,播放音乐,获取文件路径,nsthread,文件文件夹操作,plist 时间
    使用NSTimer实现倒计时,Iphone幻灯片效果+背景音乐,
    如何让你的iPhone程序支持多语言环境(本地化)
    iPhone电子书toolbar的实现
    iphone界面如何实现下拉列表
    使用NSTimer与iphone的简单动画,实现飘雪效果
  • 原文地址:https://www.cnblogs.com/darkdance/p/2266766.html
Copyright © 2011-2022 走看看