什么是C#中的最简单的方法来检查,如果硬盘是不用写在硬盘上的任何文件SSD? [英] What is the easiest way in C# to check if hard disk is SSD without writing any file on hard disk?

查看:605
本文介绍了什么是C#中的最简单的方法来检查,如果硬盘是不用写在硬盘上的任何文件SSD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在C#来检查硬盘SSD(固态驱动器),不寻求惩罚?
我用:

  ManagementClass driveClass =新ManagementClass(Win32_DiskDrive); 
ManagementObjectCollection驱动器= driveClass.GetInstances();



但其只给出了包含SSD在属性字符串,我不能依赖于<? / p>

我需要一个直接的方式来检查?


解决方案

WMI会不能够容易地确定这一点。这里有一个解决方案,是基于相同的算法,Windows 7的使用,以确定是否一个磁盘SSD(更多算法此处的 Windows 7中的增强固态硬盘,第8页和这里:的 Windows 7的磁盘碎片整理程序用户界面概述)的告诉是否SSD或者不C#



从MSDN博客中引用:




磁盘碎片整理程序着眼于通过ATA识别设备命令直接查询设备
结果。碎片整理程序问题
IOCTL_ATA_PASS_THROUGH请求,并检查IDENTIFY_DEVICE_DATA
结构。如果NomimalMediaRotationRate设置为1,则该盘是
视为SSD。最新的固态硬盘将在
设置217字(这是用于报告标称媒体
旋转速率为1)响应该命令。字217于2007年推出了
ATA8-ACS规范。



I need to check in C# if a hard disk is SSD (Solid-state drive), no seek penalty? I used:

    ManagementClass driveClass = new ManagementClass("Win32_DiskDrive");
    ManagementObjectCollection drives = driveClass.GetInstances(); 

But its only gives Strings that contain SSD in the properties, I can't depend on that?

I Need a direct way to check that?

解决方案

WMI will not be able to determine this easily. There is a solution here that's based on the same algorithm Windows 7 uses to determine if a disk is SSD (more on the algorithm here: Windows 7 Enhancements for Solid-State Drives, page 8 and also here: Windows 7 Disk Defragmenter User Interface Overview): Tell whether SSD or not in C#

A quote from the MSDN blog:

Disk Defragmenter looks at the result of directly querying the device through the ATA IDENTIFY DEVICE command. Defragmenter issues IOCTL_ATA_PASS_THROUGH request and checks IDENTIFY_DEVICE_DATA structure. If the NomimalMediaRotationRate is set to 1, this disk is considered a SSD. The latest SSDs will respond to the command by setting word 217 (which is used for reporting the nominal media rotation rate to 1). The word 217 was introduced in 2007 in the ATA8-ACS specification.

这篇关于什么是C#中的最简单的方法来检查,如果硬盘是不用写在硬盘上的任何文件SSD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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