#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\n", pLogical); pLogical += (lstrlen(szLogicalDrierStrings) + 1); } while (*pLogical != ‘\0‘); TCHAR buf[BUFF]; HANDLE hVol; hVol = FindFirstVolume(buf, BUFF); if (hVol == INVALID_HANDLE_VALUE) { printf("Error = %d\n", GetLastError()); system("pause"); return 0; } printf("%s\n", buf); //设备名称 while (FindNextVolume(hVol, buf, BUFF)) { printf("%s\n", 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; }
时间: 2024-11-10 15:22:22