如何在 Windows 中获取 SD 卡的实际大小?

发布于 2024-08-04 10:48:28 字数 450 浏览 12 评论 0原文

我们使用一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-08-11 10:48:28

您可以尝试使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文