获取硬盘驱动器的群集大小(通过代码) [英] Getting the cluster size of a hard drive (through code)

查看:99
本文介绍了获取硬盘驱动器的群集大小(通过代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过C或C ++查找用户硬盘驱动器的群集大小.硬盘使用NTFS(尽管我也很高兴知道它在其他文件系统上是如何完成的.)

I need to find the cluster size of the users hard drive, through C or C++. The hard drive uses NTFS (though I'd appreciate knowing how it's done on other file systems as well).

我想我需要的是win32 API调用的某种组合,但是我不知道是哪个.

I guess what I need is some combination of win32 API calls, but I don't know which.

例如,在Windows控制台中键入"fsutil fsinfo ntfsinfo c:"将为您提供每个群集的字节数",这正是我所需要的. (尽管出于明显的原因,我不想运行该命令并解析其输出.)

For instance, typing "fsutil fsinfo ntfsinfo c:" in the windows console gives you "Bytes per cluster", which is what I need. (Though for obvious reasons, I don't want to run that command and parse it's output.)

推荐答案

使用 GetDiskFreeSpace

BOOL WINAPI GetDiskFreeSpace(
  __in   LPCTSTR lpRootPathName,
  __out  LPDWORD lpSectorsPerCluster, // <--
  __out  LPDWORD lpBytesPerSector, // <--
  __out  LPDWORD lpNumberOfFreeClusters,
  __out  LPDWORD lpTotalNumberOfClusters
);

这篇关于获取硬盘驱动器的群集大小(通过代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆