Tom
Tom

Reputation: 3034

How to get S.M.A.R.T. info from disks?

I tried code found in Google but nothing works and in most cases it doesn't even compile (missing units, undeclared data types etc). I finally found something that looks complete but shows "The handle is invalid" error: http://rsdn.org/article/delphi/SMART.xml You can download the file from here: http://rsdn.org/article/delphi/smart/smart.zip

The problem is with function function OpenSMART(DrvNum:Byte): THandle;

hSMARTIOCTL:=CreateFile(PChar('\\.\PhysicalDrive'+inttostr(DrvNum)),GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
result:= hSMARTIOCTL;

How can I fix it or where can I find working example?

I use Delphi 7 Pro and Delphi 10.3.

Upvotes: 0

Views: 363

Answers (1)

Tom
Tom

Reputation: 3034

OK, it needs to be run as admin. Then it just works.

Upvotes: 0

Related Questions