//CAUTION BELLOW CODE DOES NOT PROVIDE SMART UNDER RAID,SATA OR PATA ONLY IDE! :P
procedure TMainFrm.doSmartClick(Sender: TObject);
var
errinfo, model, serial:
string ;
diskbytes: int64 ;
value1:integer;
value2:integer ;
value3:integer ;
value4:integer ;
value5:integer ;
value6:integer ;
value7:integer ;
value8:integer ;
value9:integer ;
value10:integer ;
value11:integer ;
value12:integer;
value13:integer ;
SmartResult: TSmartResult ;
I: integer ;
function GetYN (value: boolean):
string ;
begin
result := '
No' ;
if value
then result := '
Yes' ;
end ;
begin
value1 := (0) ;
value2 := (1) ;
value3 := (2) ;
value4 := (3) ;
value5 := (4) ;
value6 := (5) ;
value7 := (6) ;
value8 := (7) ;
value9 := (8) ;
value10 := (9) ;
value11 := (10) ;
value12 := (11);
value13 := (12) ;
listview.ViewStyle:=vsreport;
ListView.Items.Clear ;
if NOT MagWmiSmartDiskInfo (DiskNum.Value, errinfo, model, serial, diskbytes)
then
begin
if MagWmiScsiDiskInfo (DiskNum.Value, errinfo, model, serial, diskbytes)
then
ResInfo.Text := '
SCSI Serial: ' + serial
{+
', Size = ' + Int64ToCStr (diskbytes) }
else
ResInfo.Text := errinfo ;
exit ;
end ;
if naloziljeze=false
then begin
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value1 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value2 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value3 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value4 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value5)) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value6 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value7 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value8 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value9 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value10 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value11 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value12 )) ;
RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value13 )) ;
if
RzComboBox1.Items.Text='
'
then RzComboBox1.Items.clear;
button1.Click;
end;
//ResInfo.Text := 'IDE Model: ' + model + ', Serial: ' + serial +
// ', Size = ' + Int64ToCStr (diskbytes) ;
if NOT MagWmiSmartDiskFail (DiskNum.Value, SmartResult, errinfo)
then
begin
ResInfo.Text := errinfo ;
exit ;
end ;
if SmartResult.TotalAttrs = 0
then
begin
ResInfo.Text := ResInfo.Text + '
No SMART Attributes Returned - ' + errinfo ;
exit ;
end ;
LabelInstances.Caption := '
SMART Attributes' ;
with ListView.Columns
do
begin
Items [1].Caption := '
Name' ;
Items [2].Caption := '
State' ;
Items [3].Caption := '
Current' ;
Items [4].Caption := '
Worst' ;
Items [5].Caption := '
Threshold' ;
Items [6].Caption := '
Raw Value' ;
Items [7].Caption := '
Pre-Fail?' ;
Items [8].Caption := '
Events?' ;
Items [9].Caption := '
Error Rate?' ;
end ;
// ListView.Items.Add.Caption := 'Hours ' + IntToStr (SmartResult.HoursRunning) ;
//ListView.Items.Add.Caption := 'Realloc Sec ' + IntToStr (SmartResult.ReallocSector) ;
if SmartResult.SmartFailTot <> 0
then
ListView.Items.Add.Caption := '
SMART Test Failed, Bad Attributes ' +
IntToStr (SmartResult.SmartFailTot)
else
//ListView.Items.Add.Caption := 'SMART Test Passed' ;
for I := 0
to Pred (SmartResult.TotalAttrs)
do
begin
with ListView.Items.Add
do
begin
//Caption := IntToStr (SmartResult.AttrNum [I]) ;
SubItems.Add (SmartResult.AttrName [I]) ;
SubItems.Add (SmartResult.AttrState [I]) ;
SubItems.Add (IntToStr (SmartResult.AttrCurValue [I])) ;
SubItems.Add (IntToStr (SmartResult.AttrWorstVal [I])) ;
SubItems.Add (IntToStr (SmartResult.AttrThreshold [I])) ;
SubItems.Add (IntToCStr (SmartResult.AttrRawValue [I])) ;
SubItems.Add (GetYN (SmartResult.AttrPreFail [I])) ;
SubItems.Add (GetYN (SmartResult.AttrEvents [I])) ;
SubItems.Add (GetYN (SmartResult.AttrErrorRate [I])) ;
end ;
end ;
naloziljeze:=true;
end;