Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要通过 C 或 C++ 找到用户硬盘驱动器的集群大小。硬盘驱动器使用 NTFS(尽管我很高兴知道它在其他文件系统上是如何完成的)。
我想我需要的是一些 win32 API 调用的组合,但我不知道是哪个。
例如,在 Windows 控制台中键入“fsutil fsinfo ntfsinfo c:”会得到“每个集群的字节数”,这正是我所需要的。(尽管出于显而易见的原因,我不想运行该命令并解析它的输出。)
使用GetDiskFreeSpace
BOOL WINAPI GetDiskFreeSpace( __in LPCTSTR lpRootPathName, __out LPDWORD lpSectorsPerCluster, // <-- __out LPDWORD lpBytesPerSector, // <-- __out LPDWORD lpNumberOfFreeClusters, __out LPDWORD lpTotalNumberOfClusters );