9

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.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Rafael Colucci
  • 6,018
  • 4
  • 52
  • 121
  • 1
    I don't hold an answer to this question but I think that read/write speed of hard drive is not the same for large and small files. Simple logic says that you should read/write some amount of data from/to HD and then divide size of data with time difference between end & start of operation (in seconds) to get proper read/write speed, respectively. For S.M.A.R.T data I don't have any idea. – Wh1T3h4Ck5 Apr 05 '11 at 21:37
  • Yeah, thats a simple way of doing that. But i guess windows have something ready to use. – Rafael Colucci Apr 05 '11 at 22:07
  • Windows doesn't have anything built-in you can use from your code, AFAIK. It uses performance stuff for the hard disk to give the Windows Experience Index on Vista/Win7, but I don't know of any API that connects to that from your own apps. – Ken White Apr 05 '11 at 22:31

1 Answers1

13

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.

Community
  • 1
  • 1
RRUZ
  • 134,889
  • 20
  • 356
  • 483