Know how fast a Hard Drive is in Delphi

后端 未结 1 1075
栀梦
栀梦 2020-12-30 11:22

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)

1条回答
  •  执念已碎
    2020-12-30 11:51

    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.

    0 讨论(0)
提交回复
热议问题