zoukankan      html  css  js  c++  java
  • 遍历卷,遍历磁盘

    #include<windows.h>
    #include<stdio.h>
    #include<stdlib.h>
    
    #define BUFF 1024
    
    int main()
    {
        CHAR szLogicalDrierStrings[BUFF];
        ZeroMemory(szLogicalDrierStrings,BUFF);
        GetLogicalDriveStrings(BUFF, szLogicalDrierStrings);
    
        PCHAR pLogical = NULL;
        pLogical = (PCHAR)szLogicalDrierStrings;
        //C:\0D:\0......
        do 
        {
            printf("%s
    ", pLogical);
            pLogical += (lstrlen(szLogicalDrierStrings) + 1);
        } while (*pLogical != '');
        
    
        TCHAR buf[BUFF];
        HANDLE hVol;
    
        hVol = FindFirstVolume(buf, BUFF);
        if (hVol == INVALID_HANDLE_VALUE)
        {
            printf("Error = %d
    ", GetLastError());
            system("pause");
            return 0;
        }
    
        printf("%s
    ", buf); //设备名称
    
        while (FindNextVolume(hVol, buf, BUFF))
        {
            printf("%s
    ", buf); //设备名称
        }
    
        FindVolumeClose(hVol);
    
        /*
            C: 
            D : 
            E : 
            F : 
            //设备名称
            \ ? Volume{ 9757d529 - 3b7d - 11e7 - 9673 - 806e6f6e6963 }
            \ ? Volume{ 9757d52a - 3b7d - 11e7 - 9673 - 806e6f6e6963 }
            \ ? Volume{ 9757d52b - 3b7d - 11e7 - 9673 - 806e6f6e6963 }
            \ ? Volume{ 9757d530 - 3b7d - 11e7 - 9673 - 806e6f6e6963 }
        */
        system("pause");
        return 0;
    }
  • 相关阅读:
    面向对象
    ArrayList 集合
    JAVA 方法
    JAVA数组
    JAVA基础2
    JAVA基础1(语法)
    JAVA基础(jdk安装和环境变量的配置)
    数据结构练习题
    多表查询
    数据约束
  • 原文地址:https://www.cnblogs.com/DeeLMind/p/6884957.html
Copyright © 2011-2022 走看看