如何使用C语言确定存储类型(SSD驱动器或HHD.机械驱动器)
如何从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否考虑过进行读/写测试来尝试确定功能?
Have you considered doing a read/write test to try to determine capabilities ?
您可以使用 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.
这个猜测可能性很大,但我找不到更好的。在设备的标识结构中,查看其是否支持声学管理。旧的磁盘驱动器没有,但也许大多数现代磁盘驱动器都有。显然,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.
SSD 应该将自己标识为不可旋转。以 Linux 为例,您可以通过 sysfs 获取信息:
如果返回 0,则您有 SSD...
SSD are supposed to identify themselves as non-rotative. For linux, as example, you can get the info via sysfs:
If it returns 0, you have SSD...