如何使用C语言确定存储类型(SSD驱动器或HHD.机械驱动器)

发布于 2024-08-10 18:43:45 字数 45 浏览 1 评论 0原文

如何从 C 程序读取驱动器的硬件信息? (即确定驱动器是SSD还是机械盘。)

How can I, from a C program, read the hardware information of a drive? (I.e. to determine if the drive is an SSD or a mechanical disk.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

花伊自在美 2024-08-17 18:43:46

您是否考虑过进行读/写测试来尝试确定功能?

Have you considered doing a read/write test to try to determine capabilities ?

作妖 2024-08-17 18:43:46

您可以使用 win32 库中的 GetDriveType 方法,并且您也许能够区分这样,或者您使用 GetVolumeInformation 尝试从标签中确定它。

You can use the GetDriveType Method from the win32 library, and you might be able to differentiate that way, or you use GetVolumeInformation to try and determine it from the label.

仄言 2024-08-17 18:43:46

这个猜测可能性很大,但我找不到更好的。在设备的标识结构中,查看其是否支持声学管理。旧的磁盘驱动器没有,但也许大多数现代磁盘驱动器都有。显然,SSD 不需要声学管理,但我们希望他们会说不需要,而不是假装是磁盘驱动器。

This guess is a long shot but I can't find anything better. In the device's identification structure, see if it supports acoustic management. Old disk drives didn't, but maybe most modern disk drives do. Obviously SSDs don't need acoustic management but let's hope they'll say they don't, instead of pretending to be disk drives.

懷念過去 2024-08-17 18:43:45

SSD 应该将自己标识为不可旋转。以 Linux 为例,您可以通过 sysfs 获取信息:

cat /sys/block/sda/queue/rotational

如果返回 0,则您有 SSD...

SSD are supposed to identify themselves as non-rotative. For linux, as example, you can get the info via sysfs:

cat /sys/block/sda/queue/rotational

If it returns 0, you have SSD...

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