如何在 Windows 中获取 SD 卡的实际大小?
我们使用一个基于 Windows 的小型自制工具来写入操作系统、映像和包含 SD 卡上数据的 FAT 分区,然后将其在嵌入式设备中用作启动介质和数据存储。
我目前正在使用 IOCTL_DISK_GET_DRIVE_GEOMETRY 来获取SD 卡的大小。然而,由于CHS格式的限制,它并不是SD卡的真实大小。这不是一个大问题,因为只有少数扇区被浪费,但是最好使用卡上的所有可用空间。
有没有更好的方法来获取驱动器的大小?请记住,我对分区大小不感兴趣。我需要可以在 SD 卡上访问的字节(或扇区)总数。此外,驱动器可能未格式化(正确 - 我的工具创建 “太小”分区)并首先使用 Windows 对其进行格式化不是一个选择。
佛子
We're using a small self-made windows-based tool to write OS, Images and a FAT partition containing data on SD cards that will then be used in embedded devices as boot medium and data storage.
I'm currently using IOCTL_DISK_GET_DRIVE_GEOMETRY to get the size of an SD card. However, due to the limitations of the CHS format it's not the real size of the SD card. This is not a big issue, since only a few sectors are wasted, however it would be nice to use all of the available space on the card.
Is there a better way to get the size of the drive? Remember, I'm not interested in the partition size. I need the total number of bytes (or sectors) that I can access on the SD card. Also, the drive might not be formated (correctly - my tool creates
"too small" partitions) and formating it with windows first is not an option.
Fozi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用 IOCTL_DISK_GET_LENGTH_INFO。然而,这个IOCTL是在Windows XP和更高版本的操作系统中添加的。
http://msdn.microsoft.com/en-us /library/aa365178(VS.85).aspx
You can try using IOCTL_DISK_GET_LENGTH_INFO. However, this IOCTL was added in Windows XP and later OSes.
http://msdn.microsoft.com/en-us/library/aa365178(VS.85).aspx