知道Delphi中的硬盘驱动器有多快 [英] Know how fast a Hard Drive is in Delphi

查看:176
本文介绍了知道Delphi中的硬盘驱动器有多快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在撰写一个诊断程序(如珠穆朗玛峰,但更简单),我需要知道HardDrive的速度是多快。我想知道如下事情:



1 - 每秒字节数(读)

2 - 每秒字节数(写)

3 - SMART数据



我想我可以使用WMI查询这样的东西,但我不知道如何。如果我需要购买一个组件或获取一个开源软件,这并不重要。我也知道Windows Perfmoon能够做到这一点,但是我无法使用它。

解决方案

Rafael获取SMART数据可以使用WMI或Windows API。



使用WMI



获取SMART的WMI类 数据是




  • MSStorageDriver_ATAPISmartData

  • MSStorageDriver_FailurePredictData

  • MSStorageDriver_FailurePredictStatus

  • MSStorageDriver_FailurePredictThresholds

  • MSStorageDriver_ScsiInfoExceptions



root\WMI 命名空间。不幸的是,这些课程没有很好的记录。



使用WINAPI



从Windows API访问SMART数据需要更多的工作,您必须使用 DeviceIoControl CreateFile 将各个结构传递给持有数据。您可以在网络上找到许多示例。



要计算硬盘的速度



没有Windows api直接暴露这些信息。所以你必须计算这个你的自我。例如,您可以查看此应用程序 DISKSPEED 其中包括C ++中的源代码。他们使用 CreateFile 函数设置 FILE_FLAG_NO_BUFFERING($ 20000000) 标志,使得对文件句柄进行任何写入和读取的操作都可以直接进行而不被缓冲。


I am writing a diagnosis program (like everest, but simpler) and I need to know how fast a HardDrive is. I wanna know things such as:

1 - Bytes per second (read)
2 - Bytes per second (write)
3 - S.M.A.R.T data

I guess I can use WMI to query such thing, but i have no idea how. It does not matter if I need to buy a component or get a opensource one. I also know that Windows Perfmoon is able to do that, but I cannot use it.

解决方案

Rafael to obtain the S.M.A.R.T data you can use the WMI or the Windows API.

using the WMI

the WMI classes to obtain S.M.A.R.T data are

  • MSStorageDriver_ATAPISmartData
  • MSStorageDriver_FailurePredictData
  • MSStorageDriver_FailurePredictStatus
  • MSStorageDriver_FailurePredictThresholds
  • MSStorageDriver_ScsiInfoExceptions

All are located in the root\WMI namespace. unfortunately these classes are not very well documented.

using the WINAPI

To access the S.M.A.R.T data from the Windows API requires a little more of work, you must use the DeviceIoControl and CreateFile functions passing the respective structures to holding the data. you can find many sample of this on the net.

To calculate the speed of a Hard Disk

there is not a Windows api which expose directly this information. so you must calculate this your self. for an example you can check this application DISKSPEED which include the source code in C++. they uses the CreateFile function setting the FILE_FLAG_NO_BUFFERING ($20000000) flag, to make which any writes and read made to the file handle be done directly without being buffered.

这篇关于知道Delphi中的硬盘驱动器有多快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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