Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#18

AW: Betriebsstunden einer Festplatte auslesen?

  Alt 7. Nov 2010, 15:25
Kleine Erweiterung: DRIVE INVALID, wenn keine S.M.A.R.T.-Daten gelesen werden können:

Delphi-Quellcode:
.
.
.
procedure TFMain.getDriveInfos(drive: Integer; Infos: TStrings);
var
  i: Integer;
begin
  Infos.Clear;
  ReadSMART;
  if SCOP[drive].attr[0].bAttrID =0 then
  Begin
    Infos.Append('Drive '+ IntToStr(drive)+': DRIVE INVALID');
    Exit;
  End;
  for i := 0 to 255 do
  begin
    if SCOP[drive].attr[i].bAttrID = ATTR_READ_ERROR_RATE then
    begin
      Infos.Append('Drive '+ IntToStr(drive)+': S.M.A.R.T. DATA'+#13#10);
      Infos.Append(Format(
        'ATTR_READ_ERROR_RATE: %s',
        [HexToStr(SCOP[drive].attr[i].Raw[0])]
        ));
    end;
    if SCOP[drive].attr[i].bAttrID = ATTR_POWER_ON_HRS_COUNT then
    begin
      Infos.Append(Format(
        'ATTR_POWER_ON_HRS_COUNT in hours: %d',
        [SCOP[drive].attr[i].Raw[0] + (SCOP[drive].attr[i].Raw[1] * 256)]
        ));
    end;
    if SCOP[drive].attr[i].bAttrID = ATTR_TEMPERATURE_CELCIUS then
    begin
      Infos.Append(Format(
        'ATTR_TEMPERATURE_CELCIUS: %d',
        [SCOP[drive].attr[i].Raw[0]]
        ));
    end;
  end;
end;

procedure TFMain.Button1Click(Sender: TObject);
begin
  getDriveInfos(0, MeInfo.Lines);
end;

procedure TFMain.Button2Click(Sender: TObject);
begin
  getDriveInfos(1, MeInfo.Lines);
end;

procedure TFMain.Button3Click(Sender: TObject);
begin
  getDriveInfos(2, MeInfo.Lines);
end;

procedure TFMain.Button4Click(Sender: TObject);
begin
  getDriveInfos(3, MeInfo.Lines);
end;

procedure TFMain.FormCreate(Sender: TObject);
begin
  getDriveInfos(0, MeInfo.Lines);
end;

end.

Geändert von hathor ( 7. Nov 2010 um 15:40 Uhr)
  Mit Zitat antworten Zitat