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.
来源:https://stackoverflow.com/questions/5558525/know-how-fast-a-hard-drive-is-in-delphi