獲取計算機邏輯驅動器相關函式
阿新 • • 發佈:2018-12-03
程式碼:
#include <stdio.h> #include <Windows.h> int main() { DWORD l_dwLogicalDrives = GetLogicalDrives(); char s[33]={0}; itoa(l_dwLogicalDrives,s,2); printf("%s\n",s); DWORD l_dwBufferLength=26*4; char Buffer[26*4]={0}; GetLogicalDriveStringsA(l_dwBufferLength,Buffer); UINT l_dwType=GetDriveTypeA(Buffer); // 碟符根目錄,比如C:\ printf("%d\n",l_dwType); DWORD l_dwSectorsPerCluster=0; DWORD l_dwBytesPerSector=0; DWORD l_dwNumberOfFreeClusters=0; DWORD l_dwTotalNumberOfClusters=0; /* 碟符根目錄,比如C:\ */ GetDiskFreeSpaceA(Buffer,&l_dwSectorsPerCluster,&l_dwBytesPerSector,&l_dwNumberOfFreeClusters,&l_dwTotalNumberOfClusters); printf("l_dwSectorsPerCluster:%d\n",l_dwSectorsPerCluster); printf("l_dwBytesPerSector:%d\n",l_dwBytesPerSector); printf("l_dwNumberOfFreeClusters:%d\n",l_dwNumberOfFreeClusters); printf("l_dwTotalNumberOfClusters:%d\n",l_dwTotalNumberOfClusters); return 0; }
第一個:GetLogicalDrives( ),輸出結果:
第二個:GetLogicalDriveStringsA(BufferLength,Buffer),結果:
第三個:GetDriveTypeA(Buffer),結果:
第四個:GetDiskFreeSpaceA( ),結果: